Make sure your crons run on time

If you add an entry to crontab that is an interval, such as */3 (every 3 minutes), you can verify that it runs at the specified interval with a bit of awk:

[code lang=”bash”]cat /var/log/cron |grep cron-script |awk -F\: ‘{if ($2/3 == 0) print $0}’ |grep -v “:00:”[/code]

This essentially checks to see that the minute field of the timestamp is divisible by three — the interval. It’ll also run at 00 after the hour, not divisible by three, but expected.

Cron can “run late” at times due to high load situations, so if there are any irregularities in your intervals, you may wish to investigate deeper, looking for expensive processes that are chewing up precious cron time.

Leave a Reply