Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 at 12:44
up vote 41 down vote accepted

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.

share|improve this answer
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
-d + -f makes logrotate report "needs rotating" for all files, even the ones that don't match – Fluffy Apr 24 '15 at 13:12

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 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.status and goose the status date for your log back to the previous day. Now when you run logrotate manually, it will work as expected

share|improve this answer
that's is the case! – brauliobo Jun 24 '14 at 21:43
Whoa thank you so much I was going nuts here searching the problem with my configuration... – Christian Aug 19 '15 at 12:02

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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