crontab question

Jonathan S. Billings jsbillin at Princeton.EDU
Mon Mar 3 14:33:26 UTC 2008


Michael Weber wrote:
> Greetings!
> 
> I have a need to run a cron script periodically on two different
> machines.  One should run the script on even hours and the other on
> odd hours.
> 
> Is there a way to script the odd hour execution elegantly?

If the same script is shared or copied to both systems,  you could just
have the script detect which system it is running on, and have it
determine the order.  For example, each time the script runs, it leaves 
a lockfile of some sort, and only the other host can remove it and run 
the script again.

> 05 1,3,5,7,9,11,13,15,17,19,21,23 * * * root
> /usr/local/sbin/sync-help-files.sh
> 
> is nowhere near as nice or intuitive as the even hour version
> 
> 05 */2 * * * root /usr/local/sbin/sync-help-files.sh

1-23/2 will run the odd hours.



-- 
Jonathan Billings <jsbillin at princeton.edu>
Computational Science and Engineering Support (CSES)
http://www.princeton.edu/~cses/




More information about the redhat-sysadmin-list mailing list