Re: PROPOSAL to serialize cron.{daily,weekly,monthly}
begin "Artur R. Czechowski" <arturcz@hell.pl> dedi ki:
> On Sun, Sep 05, 2004 at 04:45:54AM +0300, Abdullah Ramazanoglu wrote:
--8<--
> 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.
Here is the problem: Anacron works as a fall back mechanism where cron
fails, due to various reasons, to do its job. In a normal 7/24 system
anacron never kicks in cron.xxxly batches, as cron does its job
successfully. Note that /etc/cron.d/anacron starts anacron at 7:30,
whereas cron starts cron.{daily,weekly,monthly} at 6:25, 6:47 and 6:52
respectively. Since the first job in these batches are "0anacron" which
resets anacron timer (stamps the job as "been run"), anacron never finds a
job that is missed by cron, and thus never kicks in the relevant jobs. In
the end, all cron.xxxly batches end up being managed only by cron
(/etc/crontab), hence parallel execution.
This brings up another erroneous behavior of cron/anacron couple: Namely,
the serialization is not consistent, and it depends on who happens to
manage the jobs. In a normal 7/24 operation cron manages them in parallel
fashion, whereas in exceptional cases anacron manages them in serial
fashion. This may cause the administration of a system even more
difficult, because the admin cannot rely on the fact that cron.xxxly will
always be run in parallel or in serial.
--8<--
--
Abdullah | aramazan@ |
Ramazanoglu | myrealbox |
________________| D.0.T cöm |__
Reply to: