[vox-tech] cron - not at a different time (fwd)

Jeff Newmiller vox-tech@lists.lugod.org
Wed, 3 Mar 2004 15:56:05 -0800 (PST)


I accidentally sent this only to Peter... here it is for the record:

On Wed, 3 Mar 2004, Peter Jay Salzman wrote:

> On Wed 03 Mar 04, 12:04 PM, Jeff Newmiller <jdnewmil@dcn.davis.ca.us> said:

[...]

> > If cron and anacron are both installed in Debian, /etc/crontab is
> > configured to skip daily/weekly/monthly processing, because
> > /etc/anacrontab specifies those as well, and if your machine is regularly
> > shut down, then anacron is better suited to handle it.  What burns me is
> > that one _or_ the other should be installed...  someone must have decided
> > that cron was good for some things and anacron good for others and wanted
> > both installed... leaving you erroneously thinking you were having some
> > effect by editing the daily entry in /etc/crontab.
> > 
> > In their defense, though, the solution _is_ right there in the line you
> > edited...
>  
> i'm still don't understand -- how does anacron know when, that is the
> *time* (not the date) to run?

This puzzled me too.. thanks to Steve Wormley for pointing me to the
solution:

Vixie cron processes three sets of crontabs... /etc/crontab, individual
crontabs (/var/spool/cron/username), and any crontabs found in
/etc/cron.d/.  anacron is invoked periodically by a line in
/etc/cron.d/anacron, and uses the period specs in /etc/anacrontab and
last-executed timestamps in /var/spool/anacron/* to determine whether
enough time has passed that it should invoke the daily/weekly/monthly
processing.

> i see references to the last date job X ran in /etc/anacrontab.

You do? Those should be in /var/spool/anacron/* ... for example:

--- /var/spool/anacron/cron.daily/ ---
20040303
--------------------------------------

and /etc/anacrontab should have time interval specifications:

--- /etc/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

# These replace cron's entries
1       5       cron.daily       nice run-parts --report /etc/cron.daily
7       10      cron.weekly      nice run-parts --report /etc/cron.weekly
30      15      cron.monthly nice run-parts --report /etc/cron.monthly
-----------------------

as documented in man anacrontab.

> i understand that anacron prolly looks at these dates when it first
> runs.

Every time it runs.

> i don't see any mention of anacron in /etc/crontab.  how does it run
> after bootup?

um, /etc/init.d/anacron?

I realize now that anacron cannot run separately from cron... but this is
still an absurdly complicated system just to get things to run
periodically.  Also, why retain /etc/crontab at all if /etc/cron.d is
going to be used?

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------