type in your query to search makeyougohmm
Things that ... make you go hmmtechnology music video art news reviews and muse on the web

March 22, 2007

How to check if cron is working

developers, How To — by TDavid @ 8:51 am PST
F = please no more posts like thisD = not among your best stuffC = average postB = good post, I liked itA = great post, please create more like this (2 votes, average: 5 out of 5)
Loading ... Loading ...

checking if cron is running from shell

In the UNIX world cron is used to schedule events like updating a web page, retrieving RSS feeds, changing a file and countless other activities. Among other updates, cron is used here to update the daily stock graphs at the top of the finance category page.

Yesterday, I noticed these graphs weren’t updating and logged into the shell and entered crontab -l to see if there were any errors in the crontab syntax. None. A sudo ps aux command showed cron was running (pictured above) … and yet it wasn’t firing any of the jobs.

The UNIX forum offers suggestions for making sure cron is running like checking the cron log files, using touch to a file and watching the timestamps in a cron job like this:

* * * * * touch /tmp/.cron_is_working

To see if it’s running it’s as easy as watching the timestamp on the files and seeing the time changes. If you aren’t familiar with the format, those asterisks from left to right and separated by spaces indicate:

minutes, hours (0 = 12am, 23 = 11pm), days, months, weekdays (0 = Sunday, 6 = Saturday)

EXAMPLE. let’s say you only wanted to touch a file called ‘thursawday.txt’ in the /tmp directory at 12:01 am on Thursawday (4 = Thursawday), the cron code would look like this:

1 0 * * 4 touch /tmp/thursawday.txt

What if you want to touch ‘thursawday.txt’ every five minutes of every hour on Thursawday?

0,5,10,15,20,25,30,35,40,45,50,55 * * 4 touch /tmp/thursawday.txt

If you’d like some help generating cron jobs, a couple years ago I created and shared a cron generator you’re welcome to use. It also includes keyboard hotkeys (edit, save, exit) for using common UNIX shell text editors AE and VI.

Related Posts

RSS Feed comments for this post No Comments »

Did this make you go hmm?
TrackBack URI: http://www.makeyougohmm.com/20070322/4356/trackback/

Leave a comment


By leaving a comment you consent to the Official Hmm Comment Policy

Return Home


Copyright 2003-2008 KMR Enterprises All Rights Reserved