On one of the servers I manage I was troubleshooting a problem where logrotate (check out our guide for setting up logrotate on a custom file) wasn’t running on a set of files. To troubleshoot problems with logrotate I always run the command with a specific configuration and the force (-f) and verbose (-v) options:

# logrotate -f -v /etc/logrotate.d/log.log
Ignoring /etc/logrotate.d/log.log because of bad file mode.

Handling 0 logs

I assumed it was having trouble with the file it was trying to rotate so I messed with those permissions for a while but then I looked at the permissions on the configuration file:

# ls -l /etc/logrotate.d/log.log
-rw-rw-rw- 1 root root 137 Oct  5 12:42 /etc/logrotate.d/log.log

Logrotate doesn’t like the fact that other people can write to the file so I changed the permissions so only root had write access:

# chmod 644 /etc/logrotate.d/log.log
# ls -l /etc/logrotate.d/log.log
-rw-r--r-- 1 root root 137 Oct  5 12:42 /etc/logrotate.d/log.log

Then everything worked.

# logrotate -d -v /etc/logrotate.d/log.log
reading config file /etc/logrotate.d/log.log

Handling 1 logs

rotating pattern: /var/log/resque_worker/log.log  weekly (52 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/resque_worker/log.log