Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the following new logrotate configuration:

/var/log/nexus/nexus.log {
    rotate 7
    missingok
    compress
    delaycompress
    copytruncate
    daily
}

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:

nexus.log
oldlogs.tar.gz

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

2 Answers 2

up vote 24 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
1  
In FreeBSD it's /var/run/logrotate.status –  kaleissin Nov 29 '11 at 10:07

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 at 21:43

Your Answer

 
discard

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.