How i configure logrotate to not delete the log files after rotation
logginglogrotate
There's a way to do this?
Best Answer
In your logrotate.conf (or the equivilent logrotate.d file), change the line that says "
rotate 10
(your number may be different) to a bigger number. That will tell it to keep that many days of logs. You can make it 36500, which would last you 100 years.
Adding delaycompress to the configuration section for /var/log/messages solved the problem.
From man logrotate:
delaycompress
Postpone compression of the previous log file to the next rota‐
tion cycle. This only has effect when used in combination with
compress. It can be used when some program cannot be told to
close its logfile and thus might continue writing to the previ‐
ous log file for some time.
I guess sysklogd, my syslog daemon, cannot be told to close its logfile, and thus this is necessary.
Interestingly, the original configuration I had (without the delaycompress directive), came straight out of man logrotate (except I changed weekly to daily):
I suppose having logs written to file by apache is preferred solution in terms of stability.
Imagine what might happen if your syslog will go down, or if there'll be some error in pipe command?
Why not to write your own rotation script? You could use following algorithm to avoid losing data and any downtimes.
Suppose you need to rotate file big_access_log
rename big_access_log to .big_access_log_rotating
send HUP signal to apache. It will reopen (recreate) big_access_log.
compress .big_access_log_rotating with any tool you like at any priotiry.
Personally, I just use logrotate and I don't care a lot about some data that might be lost, but I suppose logrotate is smart enough to do rotation in atomic way.
Best Answer
In your logrotate.conf (or the equivilent logrotate.d file), change the line that says "
(your number may be different) to a bigger number. That will tell it to keep that many days of logs. You can make it 36500, which would last you 100 years.