I want to set up daily logrotate for my Tomcat server' catalina.out log file but it's not working - I haven't seen the rotated log files created.
To troubleshoot, I ran logrotate -d /etc/logrotate.conf and got the following:

rotating pattern: /usr/local/tomcat/logs/catalina.out  5242880 bytes (7 rotations)
empty log files are rotated, old logs are removed
considering log /usr/local/tomcat/logs/catalina.out
  log needs rotating
rotating log /usr/local/tomcat/logs/catalina.out, log->rotateCount is 7
dateext suffix '-20151223'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
copying /usr/local/tomcat/logs/catalina.out to /usr/local/tomcat/logs/catalina.out-20151223
truncating /usr/local/tomcat/logs/catalina.out
compressing log with: /bin/gzip 

It seems like everything is working without any error. However, there is no results:

[root@gec logrotate.d]# ls -lrth /usr/local/tomcat/logs/cata*
-rw-r--r-- 1 root root  398 Dec  4 17:48 /usr/local/tomcat/logs/catalina.2015-12-04.log
-rw-r--r-- 1 root root 109M Dec 23 17:21 /usr/local/tomcat/logs/catalina.out 

My /etc/logrotate.conf:


rotate 7

# create new (empty) log files after rotating old ones

# use date as a suffix of the rotated file

# uncomment this if you want your log files compressed

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d 

My /etc/logrotate.d/tomcat:

/usr/local/tomcat/logs/catalina.out {
    rotate 7
    size 5M

What is wrong?


Interestingly, running logrotate -f /etc/logrotate.conf creates the rotation gzip files!

[root@gec logrotate.d]# ls -lrth /usr/local/tomcat/logs/cata*
-rw-r--r-- 1 root root  398 Dec  4 17:48 /usr/local/tomcat/logs/catalina.2015-12-04.log
-rw-r--r-- 1 root root 1.1M Dec 23 17:26 /usr/local/tomcat/logs/catalina.out-20151223.gz
-rw-r--r-- 1 root root 109K Dec 23 17:27 /usr/local/tomcat/logs/catalina.out

However, how do I know whether the daily cron job will work?

  • 2
    If you want to see the effect of your conf file, try running logrotate with the -v flag, as from the man page the -d flag says: "In debug mode, no changes will be made to the logs or to the logrotate state file." – fduff Dec 23 '15 at 9:42
  • Why don't you post this as an answer? As far as I can see, this is actually the source of the problem. – jstarek Dec 23 '15 at 11:20

You are running logrotate -d /etc/logrotate.conf with -d argument.

The -d argument is debug mode, you can say kind of "dry-run". It will only give you info if the logrotate will work but will not rotate the logs.

The logrotate -f worked since the -f argument specifies logrotate to force the logrotate.

Quoting from the manual of logrotate:

  • -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.

  • -f, --force Tells logrotate to force the rotation, even if it doesn't think this is necessary. Sometimes this is useful after adding new
    entries to a logrotate config file, or if old log files have been
    removed by hand, as the new files will be created, and logging
    will continue correctly.

If the logrotate -d /etc/logrotate.conf gave you output that the log will be rotate and compressed then it will surely rotate it when logrotate will go through your configuration file.


In /etc/logrotate.d/tomcat try notifempty

  • 4
    How would that be relevant to the scenario described in the question? – jstarek Dec 23 '15 at 11:21
  • The notifempty parameter says Do not rotate the log if it is empty -- but as you can see, the OP's log files are not empty. – Jeff Schaller Dec 23 '15 at 13:21

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.