1

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?

  • Are you sure that postrotate is really running when no file was rotated? It shouldn't. – rudimeier May 29 '17 at 12:53
  • I have configured logwatch.conf with – user333869 May 31 '17 at 4:59
  • I have configured logrotate.conf with size=3M rotate 2 create compress delaycompress include /etc/logrotate.d /var/log/wtmp { size=3M create 0664 root utmp rotate 1 } and running logrotate -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. – user333869 May 31 '17 at 5:10
  • Option -f tells logrotate to force the rotation. – rudimeier May 31 '17 at 5:25
1

Sorry for the mistake. I did run logrotate -d -f /etc/logrotate.conf which forces the rotation even if the conditions do not match. If I run it without the -f option everything works as desired.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.