Anacron - cron utility for desktop machines
Asheville Joe
josephj at main.nc.us
Wed Sep 24 15:57:08 EDT 2003
I turn my computer off at night, etc., so cron jobs don't always get run
when they should. I found a utility called anacron that seems to be
exactly what I want.
I installed the latest Mandrake version - no problem.
I *think* I understand how it works now. It was pretty confusing when I
first installed it. Instead of being separate from cron, it works with
it. Since it took me a while to puzzle this out, I thought it might be
interesting to others - especially since this is a Linux on the desktop
sort of thing and not for servers that run for years like many of you
seem to work with.
If I'm right about how this works, all you really have to do is install
it like the rpm did for me and just forget about it. From then on,
either cron will do it's job or anacron will catch what it missed and
run it. The last piece of the puzzle was in /etc/rc.d/init.d/anacron
which gets anacron to run in the first place as part of startup.
Please take a look at this and correct me if I've made any errors.
The sample anacrontab that was installed is: (I'm going to change
SHELL=/bin/sh to /bin/bash.)
# /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 Mandrake 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
The table format is Period (in days) | Delay (in minutes) | Job
Identifier | Command
or Enviroment-variable=Value.
That's simple enough. I guess the rest of the line after the third
field is the command e.g. "run-parts /etc/cron/daily".
What this does is run the daily, weekly, and monthly cron scripts using
/usr/bin/run-parts. However, it has a safety check to make sure things
don't get run twice (by cron and then by anacron) - see below.
I also looked at /etc/cron.daily .
In there is a file called 0anacron which 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.
anacron -u cron.daily
What this does is tell anacron that cron got there first by updating
anacron's timestamp files to today's date so it will think it's job
"cron.daily" doesn't need to run. Similar files are in cron.weekly and
cron.monthly.
Hope this was interesting.
Joe
----------------------------------
"The work of the poet comes to meet the spiritual need of the society in which he lives, and for this reason his work means more to him than his personal fate, whether he is aware of this or not." ~C.G. Jung, Modern Man In Search Of A Soul
More information about the nflug
mailing list