[CentOS] crontab and/or anacrontab ?

Tony Molloy tony.molloy at ul.ie
Thu Mar 11 14:28:59 UTC 2010


On Thursday 11 March 2010 12:50:13 Timothy Murphy wrote:
> Is one meant to have one or the other?
> If so, which is recommended?
> I have
> --------------------------------
> [tim at helen etc]$ cat anacrontab
> # /etc/anacrontab: configuration file for anacron
> 
> # See anacron(8) and anacrontab(5) for details.
> 
> SHELL=/bin/sh
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> MAILTO=root
> 
> 1       65      cron.daily              run-parts /etc/cron.daily
> 7       70      cron.weekly             run-parts /etc/cron.weekly
> 30      75      cron.monthly            run-parts /etc/cron.monthly
> --------------------------------
> [tim at helen etc]$ cat crontab
> SHELL=/bin/bash
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> MAILTO=root
> HOME=/
> 
> # run-parts
> 01 * * * * root run-parts /etc/cron.hourly
> 02 4 * * * root run-parts /etc/cron.daily
> 22 4 * * 0 root run-parts /etc/cron.weekly
> 42 4 1 * * root run-parts /etc/cron.monthly
> --------------------------------
> I didn't write either of these,
> they must have been automatically installed.
> 
> My impression is that anacrontab was ignored until recently,
> but now as far as I can see both are being read and acted on.
> 
> Any enlightenment gratefully received.
> 

Both are typically installed as part of a CentOS install. But you only need 
one or the other. Generally cron on a 24x7 machine and anacron on a laptop.
One or the otrher is mormally disabled.

cron is a fixed time schedular. I wakes up every minute and checks if there are 
any jobs to be run. It checks /etc'/crontab for system crons to run and also 
in /var/spool/cron for individual crons to be run.

e.g  from my /etc/crontab file

22 4 * * 0 root run-parts /etc/cron.weekly

says

At 22 minutes past 4am run /etc/cron.weekly


anacron is for machines that are not up 24x7 so they could miss some of the 
times when "cron jobs" were to be run. So anacron wakes up and checks the 
/etc/anacrontab file. Then it runs any jobs after a certain delay period ( not 
at a fixed time )

e.g from my /etc/anacrontab file

7	20	cron.weekly		nice run-parts /etc/cron.weekly

says

20 minutes after waking up every 7 days run /etc/cron.weekly


Hope this helps,

Tony


-- 

Chief Technical Officer.                   Tel: +353 061-202778
Dept. of Comp. Sci.
University of Limerick.




More information about the CentOS mailing list