Information Technology Reference
In-Depth Information
Commands that are executed automatically by being placed in a
crontab
file
are referred to as
cron jobs
. Commands to be executed only once at a future
time can be submitted using the
at
command instead of modifying the
crontab
s. The
at
command is described in the next section.
The two general classes of
crontab
s are system
crontab
s, which are owned
by system accounts such as root, lp, and so on, and user
crontab
s, which are
created and maintained by non-administrative user accounts.
Default cron Settings
Like other system utilities, parameters can be set to control the behavior of
the
cron
command. These settings are listed in the
/etc/default/cron
file.
The
cron
command will log its activities in the
/var/cron/log
file if the fol-
lowing entry is contained in the
/etc/default/cron
file:
CRONLOG=YES
This is the default. To disable logging, change
YES
to
NO
and reboot the sys-
tem or restart
cron
using the
/etc/init.d/cron
run control (rc) script.
Other entries that can be added to the
/etc/default/cron
include
PATH
,
which sets the
PATH
shell environment parameter for user
cron
jobs, and
SUPATH
, which sets the
PATH
shell environment variable for root
cron
jobs.
The following listing shows the
PATH
and
SUPATH
settings:
PATH=/usr/bin:/usr/ucb:
SUPATH=/usr/sbin:/usr/bin:
The crontab Files
The
/var/spool/cron/crontabs
directory contains both the system and
the user
crontab
files. These files have the same name as the account name
of the owner. For example, the
crontab
for the guest user account is named
guest
.
The
crontab
file contains entries that specify a command to execute along
with a time and frequency of execution. Commands can be executed daily,
weekly, or monthly at any time of the day.
A
crontab
entry consists of six fields separated by spaces or tabs. An asterisk
(*) is used as a placeholder in a field that is not used. Table 5.5 lists the fields
of a
crontab
entry.