Information Technology Reference
In-Depth Information
Table 5.5
The Fields of a crontab Entry
Field
Values
Description
minute
0-59
Minutes of the hour
hour
0-23
Hour of the day
day
1-31
Day of the month
month
1-12
Month of the year
weekday
0-6
Day of the week (0 = Sunday)
command
N/A
The command to execute
The following listing shows the contents of a typical root crontab file:
10 3 * * 0,4 /etc/cron.d/logchecker
10 3 * * 0 /usr/lib/newsyslog
15 3 * * 0 /usr/lib/fs/nfs/nfsfind
1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c
30 3 * * * [ -x /usr/lib/clean ] && /usr/lib/clean
Note that multiple values in a field can be specified by separating them with
a comma as shown in the weekday field on the crontab entry for logchecker.
In this example, logchecker will be executed at 3:10 a.m. every Sunday and
Thursday morning.
A critical skill for system administrators is the ability to understand and use crontab s
to schedule log maintenance, system backups, and other routine maintenance.
Manipulating crontabs
The crontab(1) command can be used to create, list, edit, and delete
crontab s. One capability of the crontab command (the capability to edit the
crontab files of other users) is available only to the superuser.
When crontab is executed without any command-line arguments, it reads
the standard input (typically the keyboard). When terminated with Ctrl+D,
the entered data is used to create the crontab (or overwrite an existing
crontab ) for the user account that executed the crontab command. When a
filename is specified as a command-line argument, the contents of the spec-
ified file are used to create/overwrite the user crontab .
When crontab is executed with an -e command-line argument, the editor
specified by the shell environment parameter EDITOR is invoked on the user
crontab . If the EDITOR parameter is not set, the ed(1) text editor is used. This
allows editing of the crontab associated with the invoking user account.
Search WWH ::




Custom Search