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

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) all versions

Issue

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

Resolution

Check the logrotate.status file

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

# cat /var/lib/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.

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

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.