Saturday, November 26, 2016

Troubleshooting logrotate and cron on Ubuntu server

My client's logrotate was not rotate the logs for months. However, manually run logrotate is fine. use debug, verbose, even force options can't find anything funny. The content of /var/lib/logrotate/status looks normal. Finally, check the cron job to see if anything wrong there.
  1. Tail /var/log/cron.log and see "Authentication token is no longer valid; new one required".
  2. Run "chage -l root" to check the aging information of root account, and "password must be changed" message shown up.
  3. Generate a new password from, then run passwd command to change to the new passwd for root. 
  4. Check /var/log/cron.log again after a cron job is executed, and the cron.log seems OK. The problem fixed.
Conclusion: Since the cron job is essential for automatic log rotation. If cron job has any problem, the log files don't get rotated even manual run has no problem at all.  

No comments: