I have configured logrotate to rotate only when the log file size is beyond a certain limit. Some logrotate definitions have postrotate scripts which seem to run every time logrotate is invoked, no matter if the log file in question has been rotated or not. Thus there is some processing going on even though logrotate does not need to change the log file.
Is there a way to skip the postrotate part if the log file has not been rotated?
postrotate
is really running when no file was rotated? It shouldn't.size=3M rotate 2 create compress delaycompress include /etc/logrotate.d /var/log/wtmp { size=3M create 0664 root utmp rotate 1 }
and runninglogrotate -d -f /etc/logrotate.conf
shows "considering log /var/log/wtmp log needs rotating" although wtmp is way below 3M. /etc/logrotate.d/syslog-ng has the same defaults and a postrotate script which says "invoke-rc.d syslog-ng reload" which is always run by logrotate although /var/log/syslog is only a few hundred kB.-f
tells logrotate to force the rotation.