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. -- Timothy Murphy e-mail: gayleard /at/ eircom.net tel: +353-86-2336090, +353-1-2842366 s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland
> Is one meant to have one or the other? > If so, which is recommended? > I have > -------------------------------- > [tim at helen etc]$ cat anacrontab[ ... ]> [tim at helen etc]$ cat crontab[ ... ]> 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.> Timothy MurphyIt is pretty "normal" to have them both on CentOS. # rpm -qf /etc/crontab crontabs-1.10-8 # rpm -qf /etc/anacrontab anacron-2.3-45.el5 man 8 anacron "DESCRIPTION Anacron can be used to execute commands periodically, with a frequency specified in days. Unlike cron(8), it does not assume that the machine is running continuously. Hence, it can be used on machines that aren?t running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron." This should make obvious why there are both of the crontabs and in which situations anacron runs through his tab and when cron runs through his. Regards Alexander
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.
Tony Molloy wrote:> 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 )...> Hope this helps,Sadly, no. If "anacron is for machines that are not up 24x7" then why run it on machines that are up all the time (which I imagine is most CentOS machines)? -- Timothy Murphy e-mail: gayleard /at/ eircom.net tel: +353-86-2336090, +353-1-2842366 s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland