1 Introducing mcron
The mcron program represents a complete re-think of the cron concept
originally found in the Berkeley and AT&T unices, and subsequently
rationalized by Paul Vixie. The original idea was to have a daemon
that wakes up every minute, scans a set of files under a special
directory, and determines from those files if any shell commands
should be executed in this minute.
The new idea is to read the required command instructions, work out
which command needs to be executed next, and then sleep until the
inferred time has arrived. On waking the commands are run, and the
time of the next command is computed. Furthermore, the specifications
are written in scheme, allowing at the same time simple command
execution instructions and very much more flexible ones to be composed
than the original Vixie format. This has several useful advantages
over the original idea. (Changes to user crontabs are signalled
directly to mcron by the crontab program; cron must still scan the
/etc/crontab file once every minute, although use of this file is
highly discouraged and this behaviour can be turned off).
- Does not consume CPU resources when not needed. Many cron daemons only
run jobs once an hour, or even just once a day.
- Can easily allow for finer time-points to be specified,
i.e. seconds. In principle this could be extended to microseconds, but
this is not implemented.
- Times can be more or less regular. For example, a job that runs
every 17 hours can be specified, or a job that runs on the first
Sunday of every month.
- Times can be dynamic. Arbitrary Guile (scheme) code can be provided to
compute the next time that a command needs to be run. This could, for
example, take the system load into consideration.
- Turns out to be easy to provide complete backwards compatibility with
Vixie cron.
- Each user looks after his own files in his own directory. He can use
more than one to break up complicated cron specifications.
- Each user can run his own daemon. This removes the need for suid
programs to manipulate the crontabs, and eliminates many security
concerns that surround all existing cron programs.
- The user can obtain an advance schedule of all the jobs that are due
to run.
- Vixie cron is implemented in 4500 lines of C code; mcron is 2000 lines
of scheme, despite the fact that it offers many more features and much
more flexibility, and complete compatibility with Vixie cron.
A full discussion of the design and philosophy of mcron can be found
in the white paper at
http://www.gnu.org/software/mcron/design.html.