12

logrotate is unable to rotate my logs. I have checked the file permissions, they are fine.

I have even tried by putting "su root root" in the configuration file, still I am facing the same issue.

Please find the relevant details below:

logrotate.conf file:

/var/log/testlog {
    compress
    delaycompress
    dateext
    maxage 180
    rotate 15
    size 1024M
    start 1
    rotate 15
    missingok
}

Debug Logs: [Using "-d" option]

rotating pattern: /var/log/testlog  1073741824 bytes (15 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/testlog
  log needs rotating
rotating log /var/log/testlog, log->rotateCount is 15
dateext suffix '-20140708'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
renaming /var/log/testlog.15.gz to /var/log/testlog.16.gz (rotatecount 15, logstart 1, i 15), 
renaming /var/log/testlog.14.gz to /var/log/testlog.15.gz (rotatecount 15, logstart 1, i 14), 
renaming /var/log/testlog.13.gz to /var/log/testlog.14.gz (rotatecount 15, logstart 1, i 13), 
renaming /var/log/testlog.12.gz to /var/log/testlog.13.gz (rotatecount 15, logstart 1, i 12), 
renaming /var/log/testlog.11.gz to /var/log/testlog.12.gz (rotatecount 15, logstart 1, i 11), 
renaming /var/log/testlog.10.gz to /var/log/testlog.11.gz (rotatecount 15, logstart 1, i 10), 
renaming /var/log/testlog.9.gz to /var/log/testlog.10.gz (rotatecount 15, logstart 1, i 9), 
renaming /var/log/testlog.8.gz to /var/log/testlog.9.gz (rotatecount 15, logstart 1, i 8), 
renaming /var/log/testlog.7.gz to /var/log/testlog.8.gz (rotatecount 15, logstart 1, i 7), 
renaming /var/log/testlog.6.gz to /var/log/testlog.7.gz (rotatecount 15, logstart 1, i 6), 
renaming /var/log/testlog.5.gz to /var/log/testlog.6.gz (rotatecount 15, logstart 1, i 5), 
renaming /var/log/testlog.4.gz to /var/log/testlog.5.gz (rotatecount 15, logstart 1, i 4), 
renaming /var/log/testlog.3.gz to /var/log/testlog.4.gz (rotatecount 15, logstart 1, i 3), 
renaming /var/log/testlog.2.gz to /var/log/testlog.3.gz (rotatecount 15, logstart 1, i 2), 
renaming /var/log/testlog.1.gz to /var/log/testlog.2.gz (rotatecount 15, logstart 1, i 1), 
renaming /var/log/testlog.0.gz to /var/log/testlog.1.gz (rotatecount 15, logstart 1, i 0), 
renaming /var/log/testlog to /var/log/testlog.1
removing old log /var/log/testlog.16.gz
error: error opening /var/log/testlog.16.gz: No such file or directory

Verbose Output:

rotating pattern: /var/log/testlog  1073741824 bytes (15 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/testlog
  log needs rotating
rotating log /var/log/testlog, log->rotateCount is 15
dateext suffix '-20140625'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
renaming /var/log/testlog.15.gz to /var/log/testlog.16.gz (rotatecount 15, logstart 1, i 15), 
old log /var/log/testlog.15.gz does not exist
renaming /var/log/testlog.14.gz to /var/log/testlog.15.gz (rotatecount 15, logstart 1, i 14), 
old log /var/log/testlog.14.gz does not exist
renaming /var/log/testlog.13.gz to /var/log/testlog.14.gz (rotatecount 15, logstart 1, i 13), 
old log /var/log/testlog.13.gz does not exist
renaming /var/log/testlog.12.gz to /var/log/testlog.13.gz (rotatecount 15, logstart 1, i 12), 
old log /var/log/testlog.12.gz does not exist
renaming /var/log/testlog.11.gz to /var/log/testlog.12.gz (rotatecount 15, logstart 1, i 11), 
old log /var/log/testlog.11.gz does not exist
renaming /var/log/testlog.10.gz to /var/log/testlog.11.gz (rotatecount 15, logstart 1, i 10), 
old log /var/log/testlog.10.gz does not exist
renaming /var/log/testlog.9.gz to /var/log/testlog.10.gz (rotatecount 15, logstart 1, i 9), 
old log /var/log/testlog.9.gz does not exist
renaming /var/log/testlog.8.gz to /var/log/testlog.9.gz (rotatecount 15, logstart 1, i 8), 
old log /var/log/testlog.8.gz does not exist
renaming /var/log/testlog.7.gz to /var/log/testlog.8.gz (rotatecount 15, logstart 1, i 7), 
old log /var/log/testlog.7.gz does not exist
renaming /var/log/testlog.6.gz to /var/log/testlog.7.gz (rotatecount 15, logstart 1, i 6), 
old log /var/log/testlog.6.gz does not exist
renaming /var/log/testlog.5.gz to /var/log/testlog.6.gz (rotatecount 15, logstart 1, i 5), 
old log /var/log/testlog.5.gz does not exist
renaming /var/log/testlog.4.gz to /var/log/testlog.5.gz (rotatecount 15, logstart 1, i 4), 
old log /var/log/testlog.4.gz does not exist
renaming /var/log/testlog.3.gz to /var/log/testlog.4.gz (rotatecount 15, logstart 1, i 3), 
old log /var/log/testlog.3.gz does not exist
renaming /var/log/testlog.2.gz to /var/log/testlog.3.gz (rotatecount 15, logstart 1, i 2), 
old log /var/log/testlog.2.gz does not exist
renaming /var/log/testlog.1.gz to /var/log/testlog.2.gz (rotatecount 15, logstart 1, i 1), 
renaming /var/log/testlog.0.gz to /var/log/testlog.1.gz (rotatecount 15, logstart 1, i 0), 
old log /var/log/testlog.0.gz does not exist
log /var/log/testlog.16.gz doesn't exist -- won't try to dispose of it
renaming /var/log/testlog to /var/log/testlog.1

Output of ls /var/log/testlog* :

/var/log/testlog  
/var/log/testlog.1  
/var/log/testlog.2.gz
  • 'testlog' is the name of a log file placed at /var/log/. I am invoking 'logrotate' directly from command-line as follows:

    logrotate logrotate.conf [my own conf file, contents are copied above]

Can somebody please provide me some hint to resolve this issue?

Thanks

4 Answers 4

6

It reports an error for not finding the oldest possible rotated log file which hasn't been created yet. So that's a bug IMO. It should not fail on that.

So what will happen is that when you have collected the max amount of rotated logs (15) the error message will go away. You can safely ignore the message in the meantime.

It looks like there is a bug report on this here.

1
  • 2
    I am still having the issue: logrotate 3.7.8 over Ubuntu
    – fguillen
    Commented May 12, 2016 at 13:06
6

You need to run with -v to actually see any changes:

-d, --debug
          Turns on debug mode and implies -v.  In debug mode, no changes will be made to the  logs  or  to  the  logrotate
          state file.
0
0

I make a file with the same name which logrotate need,

such as

/var/log/testlog.16.gz

then rerun logrotate -d xx.conf and error has gone.

This works for me.

0

I actually had a problem on one of my systems where there was a missing log file in between:

mail.log
mail.log.5.gz
mail.log.6.gz

That meant it would break trying to rename mail.log.4.gz and stop handling that folder at that point. Needless to say, the mail.log file was getting large (250Mb when the limit is supposed to be 10Mb).

I fixed the issue by renaming the files as 1 and 2 instead of 5 and 6 and re-ran logrotate and it worked as expected.

mail.log
mail.log.1.gz
mail.log.2.gz

So the bug is not quite fixed, is it?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .