How to check if logrotate is working

How to check if logrotate is working

Check that the logrotate is working as expected

See man logrotate for all the options, check it's running correctly by using verbose mode and reading the output:

logrotate -v /etc/logrotate.d/<your-log-rotate-config-file>

Is your log file growing faster than the daily/weekly interval? Use the maxsize option and check how often your cron is set to run logrotate. If logrotate is only running daily, then it will only check daily.

Example logroate with comments

/var/log/my-program.log {
        su <username> <username>
# go through 3 weekly rotations before being removed
        rotate 3
        weekly
# rotated whenever it grows over xM in size
#  (maxsize is different from 'size' option since it
# will rotate if the log has grown larger before its interval
        maxsize 100M
# Create new empty log file
        create 0660 root root
# Don't fail if the log file isn't present
        missingok
# Truncate the original log file to zero size in place after
# creating a copy- needed since uwsgi holds onto the same 
# file handel and wont write to the new one
        copytruncate
}
Collect recurring payments with Subscribie - Try Now