Re: question about cron and anacron
On Fri, Apr 13, 2007 at 11:05:02PM +0200, Florian Kulzer wrote:
> On Fri, Apr 13, 2007 at 13:09:43 -0600, Paul E Condon wrote:
> > When I moved to Etch, I noticed something strange, and
> > am looking for an explanation. My cron job for doing
> > daily backups started doing the job at the wrong time.
> >
> > It turns out that the move to Etch somehow installed
> > anacron on a system that is supposed to be left on and
> > it was anacron that was actually running the script.
> >
> > But how? I look at the code in /etc/crontab and in
> > /etc/cron.daily/0anacron and I think I see that it
> > is impossible for anacron to be run on a daily basis:
> >
> > /etc/anacron contains a line:
> > 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
>
> Are you sure this snippet is from /etc/anacrontab? It looks like a line
> from /etc/crontab to me. (I cannot find "/etc/anacron" anywhere in
> Debian, so I assume you mean "...tab".)
Sorry. It is from crontab. And, it shows that if anacron is installed
run-parts is not run for cron.daily (I think).
>
> > This line invokes run-parts only if anacron is _not_ installed. And,
> >
> > $ ls /etc/cron.daily/
> > 00test-env 10chkpnt aptitude exim4-base logrotate modutils standard
> > 0anacron apt bsdmainutils find man-db samba sysklogd
> >
> > And,
> > script 0anacron contains:
> > #!/bin/sh
> > #
> > # anacron's cron script
> > #
> > # This script updates anacron time stamps. It is called through run-parts
> > # either by anacron itself or by cron.
> > #
> > # The script is called "0anacron" to assure that it will be executed
> > # _before_ all other scripts.
> >
> > test -x /usr/sbin/anacron || exit 0
> > anacron -u cron.daily
> > <end>
> >
> > But how is this script executed usefully? Since cron doesn't do
> > run-parts /etc/cron.daily if anacron is installed?
> >
> > Further, it appears that cron.daily scripts _are_ being run daily, ---
> > at 7:35am. Why 7:35am? Where is that time set? It is _not_ a time
> > that is in /var/spool/anacron. I can't think of anywhere else to look.
>
> Do you by any chance boot the system around 7:30am every day? Anacron's
> default delay for the daily jobs is 5 minutes.
>
> > There is something, somewhere, that is doing this. Where?
>
> This is how I understand it:
>
> /etc/init.d/anacron starts anacron as a daemon in the background during
> boot (unless the system is running on batteries at that moment). This
> daemon handles all the jobs specified in /etc/anacrontab. The default
> configuration causes anacron to take over all daily, weekly and monthly
> cronjobs. Anacron determines how many days have passed since each of
> these jobs was run the last time. If this period is longer than what is
> specified in anacrontab then anacron will start the job after a certain
> delay (which is also defined in anacrontab). The "0anacron" jobs make
> sure that the timestamps in /var/spool/anacron get updated whenever
> cronjobs are executed.
>
> The "test -x /usr/sbin/anacron" statements in /etc/crontab make sure
> that cron does not interfere with anacron, even though cron still takes
> care of the hourly jobs itself.
>
> --
> Regards,
> Florian
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
--
Paul E Condon
pecondon@mesanetworks.net
Reply to: