Logrotate maxsize with minsize

logrotate

I wonder if maxsize and minsize can both be added with a specified time interval and can thus coexist. With these options both the size and timestamp of a log file are considered, so if it happens that a log file grows bigger than maxsize just before the 'deadline' specified by the time interval, the following rotation would rotate a very small log file. So again I wonder if adding a minsize would skip the expected rotation if the file is too small in size:

/var/log/mylog {
  ...
  daily
  minsize 50K
  maxsize 10M
  ...
}

Best Answer

There are multiple switches here. Frequency(weekly, monthly etc), size params, -f flag and the cron job frequency. To add to the confusion, it seems the order of operations in the config file also matters..

-f will force a rotation

minsize means the log size should be at least minsize for the frequency rotation to happen. A daily frequency (called daily from cron) will do nothing if size is less than minsize.

maxsize means, in addition to the frequency run, if the size is over maxsize a rotation can happen. For ex. if a config with weekly frequency is called daily, and if the size is bigger than the maxsize, rotation can happen.

size - May be it should not be combined with frequency. Control the frequency from cron.