Logrotate: "log does not need rotating" why?

Most likely, the log file is less than a day old and/or has been rotated within the last day and logrotate remembers the history.

If you add -f it'll force a rotation if you really want to (although not 100% sure how that interacts with -d).

You can look at the history, location depends on your distribution, but might be /var/lib/logrotate/status. That file shows when logs were last rotated.


The first time you run logrotate with a new log configuration it doesn't know when the last log rotation occurred, so it just writes a status line in /var/lib/logrotate/status to the effect that it was run today.

When it subsequently runs the following day, it sees that the log is a day old and rotates it as expected. If you don't want to wait, edit logrotate's status file and goose the status date for your log back to the previous day.

When you run logrotate manually, it will work as expected


Sometimes even if you run logrotate manually, this won't work if you do it the same day and have dateext where default value doesn't include senconds (e.g. -%Y%m%d). Not even if you modify logrotate's status file or when using size directive (e.g. size 200M). At least on CentOS 6, logrotate will fail to rotate your log file because it already exists.

To solve this, you need to use dateformat instead of dateext, with a value like: %Y%m%d%s.

See man logrotate for more information.

Tags:

Logrotate