1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
Suggested configuration of Anacron on a Debian system
=====================================================
A lot of packages install maintenance scripts (e.g., to rotate the log
files) into the /etc/cron.daily, /etc/cron.weekly, and
/etc/cron.monthly directories. Usually, these scripts are controlled
by `cron', but this doesn't work well on systems which are not running
24 hours a day. (With cron, you'll have to specify a certain time when
the jobs a run. If the system is done at that time, the jobs will not
get executed.)
Anacron has been designed to handle exactly this situation: By
installing an /etc/anacrontab file like the one below, anacron will
take care of the scripts in the /etc/cron.* directories:
----------cut-here-------------
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# These entries are useful for a Debian system.
1 5 cron.daily run-parts /etc/cron.daily
7 10 cron.weekly run-parts /etc/cron.weekly
30 15 cron.monthly run-parts /etc/cron.monthly
----------cut-here-------------
Since anacron is not running in daemon mode (it exits after the jobs
have been executed once) one has to start anacron at boot-up time (via
the /etc/init.d/anacron script) and by cron once a day (that's
necessary if you should leave your system running over night).
For this, it's suggested to have the following entries in your
/etc/crontab, so cron will make sure they are executed:
42 6 * * * root run-parts /etc/cron.daily
47 6 * * 7 root run-parts /etc/cron.weekly
52 6 1 * * root run-parts /etc/cron.monthly
30 7 * * * root /usr/sbin/anacron || true
Since this would cause the cron.daily jobs to be executed twice if the
system is powered on between 12:00pm and 6:42am, the
/etc/init.d/anacron script, which starts anacron at boot up, only runs
anacron if it's later than 7:30am in the morning. In addition, anacron
will notice that `cron' already executed the jobs by the special
/etc/cron.*/0anacron scripts.
This setup results in the following behaviour:
system boot up job execution
====================== ====================
12:00pm -- 6:42am 6:42am
6:42am -- 7:30am 7:30am
7:30am -- 12:00pm at boot up time
If you want to see what anacron is doing, you can have a look at the
/var/log/syslog or /var/log/messages file.
That's all!
--
Christian Schwarz <schwarz@debian.org>
|