How to debug logrotate warnings or errors when logrotate is not running correctly

Solution Verified - Updated -


  • Red Hat Enterprise Linux (RHEL) all versions


How to debug logrotate warnings or errors when logrotate is not running correctly


Check the logrotate.status file

  • Check your logrotate.status file to see which files rotated:

    # cat /var/lib/logrotate/logrotate.status

Run logrotate in a debug mode

  • Run the logrotate command manually in a debug mode and check for errors:

    # /usr/sbin/logrotate -d /etc/logrotate.conf

Identify a configuration file causing the issue

  • Depending on the errors reported in the debug output, fix configuration issues in /etc/logrotate.conf, in configuration files in /etc/logrotate.d/, or other issues reported in the debug output.

Re-run logrotate in the debug mode

# /usr/sbin/logrotate -d /etc/logrotate.conf

If no errors appear, logrotate should work properly.

Avoid sharing logrotate.status file in different logrotate instances

  • The system might has multiple logrotate configuration instances which share same logrotate.status file. This cause conflict.
  • Each configuration instance must have each different logrotate.status file. Confliction can cause unpredictable issue.
  • Add --state /path/to/status_filename option to isolate each logrotate configurations.

    $ cat /etc/cron.daily/logrotate 
    /usr/sbin/logrotate /etc/logrotate.conf       <<=== This use default '/var/lib/logrotate/logrotate.status'
    $ cat /etc/cron.hourly/logrotate_rsyslog 
    /usr/sbin/logrotate /etc/logrotate_rsyslog.conf     <<=== Also use default '/var/lib/logrotate/logrotate.status', CONFLICT!

Root Cause

In this example, the root cause is a missing directory /var/log/conman.old. Creating the directory solves the issue:

# mkdir /var/log/conman.old

Diagnostic Steps

  • Confirm if cron service is running correctly with:

    # systemctl status crond.service
  • Sometimes some warnings or errors are created in the /var/log/messsages file. For example:

    logrotate: ALERT exited abnormally with [1]
  • The logrotate command has an argument -d, which turns on a debug mode. In the debug mode, no changes will be made to the logs or to the logrotate state file. If needed, the debugging output can be redirected into a file (e.g. /tmp/logrotate.debug), which may be very useful for debugging:

    # /usr/sbin/logrotate -d /etc/logrotate.conf 2> /tmp/logrotate.debug
  • Example of a debugging output:

    reading config file /etc/logrotate.conf
    including /etc/logrotate.d
    reading config file acpid
    reading config info for /var/log/acpid 
    reading config file conman
    reading config info for /var/log/conman/* 
    olddir is now /var/log/conman.old/
    error: conman:21 error verifying olddir path /var/log/conman.old/: No such file or directory

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.