Fixing Logrotate Rotating Its Own Files

From time to time I come across a server that has had logRotate setup in such a way that it is rotating its own files creating hundreds of copies and increasing disk usage rather than controlling it

This is caused by a misconfiguration of the logrotate config file. The file that is causing the problems can normally be found be running the following command

user@host$ grep '*' /etc/logrotate.d/*
/etc/logrotate.d/misconfiguredFile:/path/to/logs/* {

Which should display all of the paths that include a wild card that are being checked and rotated. The problem happens when the file path end s with a wildcard, as on the next run the newly rotated files will be checked and rotated again.

The simple way to fix this is to either specify which files need to be rotated exactly, or add the expected suffix to the path (i.e. /path/to/dir/*log).


Tags: logrotate linux sysadmin