Mystified by crontab/anacrontab

Timothy Murphy gayleard at eircom.net
Mon Mar 1 15:56:03 UTC 2010


I'm trying to understand how cron works nowadays.
I've been comparing my Fedora-12 laptop
with my CentOS-5.4 desktop,
and am slightly baffled by the difference between them.

On the Fedora-12 system the venerable /etc/crontab is empty,
and the work to be done is listed in /etc/anacrontab .
As far as I can make out, there is a program /etc/cron.d/0hourly
which every hour runs /etc/cron.hourly,
which in turn runs a program 0anacron,
which presumably checks /etc/anacron.daily, etc.

I take it this roundabout process is intended
to deal with the case where a laptop is only running
for part of the time?

In any case, the system seems to work well enough.
The programs that run are listed in /var/log/cron .

On my CentOS desktop, both /etc/crontab and /etc/anacrontab
list cron.daily, cron.weekly and cron.monthly ,
and crontab also lists cron.hourly .
But I see nothing in /etc/cron.d to run anacron ,
so it is not clear to me if /etc/anacrontab plays any role.

Also I get no messages in /var/log/cron to say
what individual programs are run hourly, daily, etc.
I'm just told eg
---------------------------------------
Jan 31 04:22:01 helen crond[27497]: 
    (root) CMD (run-parts /etc/cron.weekly)
Jan 31 04:22:01 helen anacron[27501]: 
    Updated timestamp for job `cron.weekly' to 2010-01-31
---------------------------------------
Since the second message is from anacron,
I assume that crond has started anacron running,
although if that is so it is not mentioned in "man crond".

Also the individual scripts/programs that are run
are not listed in /var/log/cron ,
although I think that may just be an oddity or omission
on the part of CentOS, which does not run "logger" in run-parts 
as Fedora does

I see that /usr/bin/run-parts does include
---------------------------------------
    $i 2>&1 | awk -v "progname=$i" \
        'progname {
        print progname ":\n"
        progname="";
        }
        { print; }'
---------------------------------------
but I'm not sure what happens to material like this
which would appear on the screen if the program were run directly?

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



More information about the users mailing list