From the man page of logrotate:
minsize size
Log files are rotated when they grow bigger than size bytes, but not before the additionally specified time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When minsize is used, both the size and timestamp of a log file are considered.size size
Log files are rotated when they grow bigger than size bytes. If size is followed by k, the size is assumed to be in kilobytes. If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100Gare all valid.
I set size as 5M and interval as weekly thinking that the logs would get rotated on a weekly basis and additional rotation would occur if the size of the log exceeds 5M. But what happens is that the log does not get rotated unless it exceeds 5M, which seems to be what minsize is supposed to do.
Am I interpreting the manual wrongly? How do I get the log to rotate on a weekly basis AND if it exceeds 5M?
EDIT:
I am not sure whether the following information is relevant, but just to supplement:
I am using rsyslog to do the main logging for messages, secure, cron, maillog, boot. The following are the rotation date and file size of the penultimate logs where size and interval are set as described above:
filename rotation date file size
messages 20130129 5.3MB
secure 20130113 5.1kB
cron 20130113 3.6kB
maillog 20130113 1.1kB
As can be seen, only messages get rotated.
EDIT2:
I should have check with man logrotate
. They actually upgraded it with the maxsize option. This should be what I am looking for:
maxsize size
Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When maxsize is used, both the size and timestamp of a log file are considered.