Re: Mystified by crontab/anacrontab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/01/2010 09:56 AM, Timothy Murphy wrote:
> 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?

In CentOS 5, anacron is started by init on entry to any of runlevels
2-5.  The anacron process checks /var/spool/anacron to see if there
are any overdue jobs, runs (after a delay) any that are needed, and
then terminates.  As long as the system is up, scheduled jobs are
handled by cron via the "run-parts" lines in /etc/crontab.  The
"0-anacron" jobs in each of the cron.{hourly,daily,weekly,monthly}
directories do nothing but update the timestamp in /var/spool/anacron
so that the next time you boot (or change runlevels) anacron can
see whether anything needs to be done.

The situation in Fedora 12 is a bit more complex.  Once an hour,
as instructed by /etc/cron.d/0hourly, the cron daemon will run all
the jobs in /etc/cron.hourly and the first of those is the
0anacron job that will, if you are running on AC power, start an
anacron process to run any needed {daily,weekly,monthly} job.
It's done that way to provide a centralized place for checking
that the machine is not running on battery and for adding random
delay to the starting of jobs, as some of those might be sending
data to a central server and you don't want all the machines on
your network to do that simultaneously.

Hope that clarifies things.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux