3

If I run logrotate I get log does not need rotating (log has been already rotated) and the log file is not rotated. Why that?

My log rotate conf:

/var/log/capp/*.log {
    missingok
    rotate 90
    daily
    notifempty
    compress
    delaycompress
}

Before I run logrotate I remove the line

"/var/log/capp/server.log" 2019-4-1-7:0:0

from file /var/lib/logrotate/logrotate.status

logrotate output:

/> logrotate -v /etc/logrotate.d/capp 
reading config file /etc/logrotate.d/capp
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /var/log/capp/*.log  after 1 days (90 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/capp/server.log
  log does not need rotating (log has been already rotated)

and the log file is not rotated:

/> ls -la  /var/log/capp/server.log*
-rw-r--r-- 1 capp capp 272962507  1. Apr 07:00 /var/log/capp/server.log
1

May be logrotate will be only on the second run begin to rotate log files. Seems that if no entry for that file is in /var/lib/logrotate/logrotate.status logrotate will be not rotate the file. So the trick was for me to change in /var/lib/logrotate/logrotate.status the line

"/var/log/capp/server.log" 2019-4-1-7:0:0

to

"/var/log/capp/server.log" 2019-3-31-7:0:0

... and logrotate began to rotate the server.log file

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.