some log system only collect *.log and rotatelogs with option -n will gen file log.1 log.2 can't be collect by log system so rotatelogs need an option to make log file suffix fixed
-n is meant for circular set of files that overwrites itself, like short-term trace. maybe it's not a good fit if you expect it to be collected. Not using -n means you can choose whatever filename you like. what's drawing you to -n in this case?
i want save log with 50M per file, and two file for rotate. total 100m space is there a good method to gen log file xx.1.log xx.2.log or xx.2022-xxx(date).log
The examples here show how to use a format string in the filename argument, you can tack ".log" onto the end. Of course your 2nd arg will be "50M".
Whoops, never pasted: https://httpd.apache.org/docs/2.4/programs/rotatelogs.html
while true; do echo 123; done | rotatelogs -n2 1.%Y-%m-%d-%H_%M_%S.log 1k Cannot use -n with % in filename if not append -n2, it will gen many log file how to make a limit of number of file
(In reply to max from comment #5) > while true; do echo 123; done | rotatelogs -n2 1.%Y-%m-%d-%H_%M_%S.log 1k > Cannot use -n with % in filename > > > if not append -n2, it will gen many log file > > how to make a limit of number of file you can't do both at the same time with rotatelogs directly. With -n, you could add a hard link to each file with a simple -p script: ``` #!/bin/bash CURFILE=$1 PREVFILE=$2 ln -f $CURFILE ${CURFILE}.log ``` Or without -n, use something like logrotated to purge old log files.
so it is too bother so i think it can add option to control log file suffix when with -n option can save log file with x.1.log x.2.log thanks