I have the following new logrotate configuration:

/var/log/nexus/nexus.log {
    rotate 7

When I run logrotate -d nexus, I get the following:

reading config file nexus
reading config info for /var/log/nexus/nexus.log

Handling 1 logs

rotating pattern: /var/log/nexus/nexus.log  after 1 days (7 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/nexus/nexus.log
  log does not need rotating

My /var/log/nexus/ folder contains the following:


Why isn't LogRotate rotating the nexus.log file? What I was expecting was that the nexus.log file would have been truncated and a new file, something like nexus.log-201106241000, would have been created.

  • Also, remember, when you use the -d option, IT DOES NOT ROTATE LOGS. It shows you what it WOULD do it run without the option, like a game plan. Caused me some serious headaches when I thought I could see them rotating, and then they were still there. – Maxwell Flanders Apr 1 '16 at 12:44

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.

  • 4
    In FreeBSD it's /var/run/logrotate.status – kaleissin Nov 29 '11 at 10:07
  • Also check for possible use of the -s argument in the invocation for status file location – JGurtz Oct 6 '14 at 21:22
  • 2
    -d + -f makes logrotate report "needs rotating" for all files, even the ones that don't match – Fluffy Apr 24 '15 at 13:12
  • To add to this, editing the date in the status file to be older than the rotation policy is enough to convince logrotate it needs to rotate the log when it runs again. – Centimane Oct 25 '17 at 12:52
  • On CentOS, I modified /var/lib/logrotate.status to get logrotate working. As indicated by EightBitTony, the daily logrotate will remembers the history. Unless the file is in the history already with a date in the past, logrotate won't rotate the file. – Mark Jan 17 '19 at 21:45

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.


Beware that by running

logrotate -vdf /etc/logrotate.conf

the event although only simulated will be logged to /var/lib/logrotate.status and subsequent logrotate runs will reply with the mentioned

log does not need rotating
  • 1
    I cannot reproduce that on Ubuntu (16.04 and 17.04). If "/var/lib/logrotate.status" is used, you must be used another distro. Ubuntu logs to "/var/lib/logrotate/status". – Philipp Claßen Jul 28 '17 at 10:12
  • 2
    @Philipp Claßen: You are right this (status file placed at /var/lib/logrotate.status) has been observed while debugging configuration of Logrotate 3.10 on Alpine linux 3.5 within a docker container. But there is no Ubuntu flag in the question definition, is it? – helvete Jul 28 '17 at 12:22
  • 1
    Yes, it's alright. I would just mention it because Ubuntu is so popular. I assume many people read this question because they want to fix their server, which today often runs with Ubuntu. – Philipp Claßen Jul 28 '17 at 13:05
  • 1
    OK, that's right. To be complete I can add that the locationo of the status file at Centos 7 distro is at /var/lib/logrotate/logrotate.status – helvete Jul 28 '17 at 13:09

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.