Fixing logrotate "bad file mode" error

Viewing the blog post

Posted in Linux, Ubuntu on Oct 20, 2017

I was trying to figure out why a Ubuntu 16.4 LTS server was not running logrotate for a custom rotation file and directory, in doing so it was not clear what was going wrong.

When manually running logrotate I was getting the bad file mode error, it was useful to use the debug -d and verbose -v options to see any extra information eg:

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

Handling 0 logs

In my case it related to logrotate not being happy with both the file and directory permissions that the mylog file was configured to use. We need root:root access with only write permissions for the root users.

# chmod 644 /etc/logrotate.d/mylog

Another useful option if the logrotate configuration file is not being run is the force -f option.