Module Release January 2004: Automate and Schedule System Administration Tasks
This month's offering deals primarily with system scheduling and
automation using the commands called at and
cron.
LPI Objective 1.111.4 (“Automate system administration tasks by
scheduling jobs to run in the future”) expects you to be able to:
“use cron or anacron to run jobs at regular intervals
and to use at to run jobs at a specific time. Task include managing cron
and at jobs and configuring user access to cron and at
services.”
The module is divided roughly 50:50 between the at and
cron commands, with an introductory foil explaining the basic
difference in their usage, i.e., the use of at for scheduling
one-off commands and the use of cron for scheduling regularly
repeated commands.
As a one-off oriented tool, at is often configured using an
interactive interface. For example, in a shell, you tell it the date and
time that you want something to occur and it prompts you to specify the
precise command line to run at that time. Instructions like this are then
queued up so that the ‘at daemon’ (atd) can execute
them when the specified time arrives.
If the instructions that you want to run are fairly long and complicated,
you can direct at to take them from a pre-written text file,
rather than prompting you for interactive input. This is often convenient
when you have to provide a large numbers of environment variables for the
instructions to run under, i.e., the at command does not
automatically inherit these variables from your shell. Once given,
at commands can be later reviewed and deleted using the
atq command.
Scheduling regular events with cron can be a little more
tricky to learn, but only because the crontab (cron table) which is
used to specify the time periods between events is rather terse. Once its
column order and syntax has been memorised through practice, using
cron becomes a relatively easy task. Text file tables in
/etc/cron.d specify the regularity with which a command should run,
for which user it should be run, alongside the command name and its
options.
The last few foils of the module deal with managing usage of
cron on a multi-user system. In particular, they explain how
it is possible to schedule jobs for individual users and for system
administrators differently.
|