I've specific problem with logrotate which is rotating before reaches the limit - set by maxsize
logrotate version - 3.8.6
I've a custom logrotate file
/var/web/log/access_log
{
rotate 40
maxsize 200M
missingok
compress
}
and logrotate is set in crontab without -f and rotate logs almost every hour despite it did not reach the maxsize listed below (logs are rotated with few MBs):
95642 Sep 8 08:29 access_log.2020-09-08_08.gz
86705 Sep 8 09:29 access_log.2020-09-08_09.gz
70344 Sep 8 09:59 access_log.2020-09-08_10.gz
86491 Sep 8 10:59 access_log.2020-09-08_11.gz
117124 Sep 8 11:59 access_log.2020-09-08_12.gz
106386 Sep 8 12:59 access_log.2020-09-08_13.gz
113683 Sep 8 13:59 access_log.2020-09-08_14.gz
104494 Sep 8 15:29 access_log.2020-09-08_15.gz
99380 Sep 8 17:00 access_log.2020-09-08_17.gz
87250 Sep 8 19:30 access_log.2020-09-08_19.gz
Now:
8632827 Sep 9 12:56 access_log
The output:
empty log files are rotated, log files >= 209715200 are rotated earlier, old logs are removed
considering log /var/web/log/access_log
log needs rotating
... Sep 9 13:00 access_log.2020-09-09_13.gz
Can sb tell me what is wrong? Why are logs rotated before size limit? Thanks
maxsize
, so the accepted answer is wrong. Your problem is caused by an interaction of the settings of thecron
period, and whatever you specified as the rotate period in your config file.