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

Re: PROPOSAL to serialize cron.{daily,weekly,monthly}



Hello,

On Sun, Sep 05, 2004 at 04:45:54AM +0300, Abdullah Ramazanoglu wrote:
> Current Situation:
> cron.daily, cron.weekly, and cron.monthly gets triggered off at specific
> times (everyday at 6:25, Sunday at 6:47 and 1st of the month at 6:52,
> respectively) regardless of whether previous batch of maintenance scripts
> has finished or not. This may result in parallel execution of scripts from
> several batches, although each batch in itself is serialized.
[cut]

> /etc/crontab (snippet)::
> # Original, commented out.
> # m h dom mon dow user	command
> #25 6 * * * root test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily
> #47 6 * * 7 root test -e /usr/sbin/anacron || run-parts --report /etc/cron.weekly
> #52 6 1 * * root test -e /usr/sbin/anacron || run-parts --report /etc/cron.monthly
> #
> # Instead, following is put into service. Note that it starts just past
> # midnight instead of 6:25. Also, while irrelevant, it is run independent
> # of whether anacron is installed or not.
> 03 0  * * *   root    nice run-parts --report /etc/cron.daily
Interesting...

> /etc/anacrontab (snippet)::
> # Original, commented out. Change to anacrontab is of secondary nature.
> # 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
> #
> # Only difference is an increase in the inactivity periods for weekly and
> # monthly runs. This is because, since these batches don't start at a
> # precisely predefined time anymore, it may cause race conditions with
> # "just in time" inactivity periods. They were too tight anyway, and
> # monthly inactivity period was incorrect even before this fix (as is in
> # woody), because it kicks in incorrectly when a specific month has 31
> # days.
> 1   5   cron.daily    nice run-parts --report /etc/cron.daily
> 8   10  cron.weekly   nice run-parts --report /etc/cron.weekly
> 32  15 cron.monthly   nice run-parts --report /etc/cron.monthly
So, you are still using anacron.

Let's see...

>From man anacron:
       -s     Serialize execution of jobs.  Anacron will not start a  new job
              before the previous one finished.

And some checking.
Preparation:
First, I've created task zzz-long in cron.{daily,weekly,monthly}:

#!/bin/bash
logger -t long "daily start"
sleep 360
logger -t long "daily stop"

(well, daily is replaced with weekly or monthly in cron.{weekly,monthly}

Second: I removed all files from /var/spool/anacron/ directory.

All other setting are unchanged, there is default, current upgraded sarge.
Then I reboot the box to get exactly the same behavior as usually when
maintenance scripts are runned.

Let's see what's happened:
arturcz@doppelmist:~$ ps auxw | grep anacron
root      2110  0.0  0.2  1728  768 ?   Ss   13:18   0:00 /usr/sbin/anacron -s

So, system logs now:
Sep  7 13:18:22 doppelmist anacron[2110]: Will run job `cron.daily' in 5 min.
Sep  7 13:18:22 doppelmist anacron[2110]: Will run job `cron.weekly' in 10 min.
Sep  7 13:18:22 doppelmist anacron[2110]: Will run job `cron.monthly' in 15 min.

That means:
 - cron.daily run at 13:23
 - cron.weekly run at 13:28
 - cron.monthly run at 13:33

Later:
Sep  7 13:23:22 doppelmist anacron[2110]: Job `cron.daily' started

Well, good.

Sep  7 13:27:25 doppelmist long: daily start

So, it takes 4 minutes to run all daily scripts, then, the last one has been
run.

Sep  7 13:33:25 doppelmist long: daily stop

Correct, there was 6 minutes sleep. But hey, WHAT'S WITH WEEKLY AND MONTHLY?!!!

Erm, weekly has started immediatly before daily:

Sep  7 13:33:25 doppelmist anacron[2110]: Job `cron.daily' terminated
Sep  7 13:33:25 doppelmist anacron[2110]: Job `cron.weekly' started

So, just for documenting the whole experiment:

Sep  7 13:33:28 doppelmist long: weekly start
Sep  7 13:39:28 doppelmist long: weekly stop
Sep  7 13:39:28 doppelmist anacron[2110]: Job `cron.weekly' terminated
Sep  7 13:39:28 doppelmist anacron[2110]: Job `cron.monthly' started
Sep  7 13:39:43 doppelmist long: monthly start
Sep  7 13:45:43 doppelmist long: monthly stop
Sep  7 13:45:43 doppelmist anacron[2110]: Job `cron.monthly' terminated (mailing
 output)
Sep  7 13:45:43 doppelmist anacron[2110]: Normal exit (3 jobs run)

Well, this is a boot sequence. Now, let's see what's happened on boxes running
24/7.

/etc/cron.d/anacron:
30 7    * * *   root    test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null

So, anacron is started in exactly the same way as after booting system.

Abdullah said:
> This may result in parallel execution of scripts from
> several batches, although each batch in itself is serialized.

I just proof that this is not true. So, there are two possible hypothesis.
1. Anacron in woody has broken -s functionality.
2. There is sth. wrong with Abdullah's configuration.

Anyone willing to repeat my experiment on woody machine?

Regardles of it's result there is no need to change anything with crontab,
anacron, fcron etc...

Cheers
	Artur
-- 
http://42.pl/url/813



Reply to: