Running cron jobs at the right time

Tuesday, January 24th, 2006 - Español English

There are two ways of programming the time that cron jobs are run on SuSE Linux systems. One is adding entries to the user’s crontab using crontab -e, the other adding scripts (be it linked or copied) to the directories /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly.

But the time, using the second method, is not configured the usual way: we see in /etc/crontab that every 15 minutes /usr/lib/cron/run-crons is run, a script which compares the timestamps of certain files with the current time in order to decide which cron jobs are to be run. These files are located at /var/spool/cron/lastrun and, quite expectedly, are named cron.hourly, cron.daily, etc.

So, if we want the daily jobs to be run at 6:00 AM, we must touch those files:

touch -t 200601240600 /var/spool/cron/lastrun/cron.daily

And that’s all. I don’t know when crontab usage was deprecated for daily, weekly, etc. task programming in SuSE, but it seems it was long ago.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>