Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

crontab(1) OSS Shell and Utilities Reference Manual
Two numbers separated by a dash to indicate an inclusive range.
A list of numbers, separated by commas, which selects all numbers in the list.
An asterisk, meaning all legal values.
Days can be specified by two fields (day of the month and day of the week). If you
specify both as a list of elements, both are adhered to. For example, the following entry:
0 0 1,15 * 1 command
would run command at midnight on the first and fifteenth days of each month, as well as
every Monday. To specify days by only one field, the other field should contain an *
(asterisk).
The cron program runs the command named in the sixth field at the selected date and
time. If you include a % (percent sign) in the sixth field, cron treats everything that pre-
cedes it (in that field) as the command invocation, and makes all that follows it available
to the standard input file, unless you escape the percent sign (\%) or double quote it
("%"). A % (percent sign) in the sixth field is translated to a newline character.
The shell runs only the first line of the command field (up to a % or End-of-Line). All
other lines are made available to the command as the standard input file.
Blank lines and lines whose first nonblank character is # (pound sign) are treated as com-
ments and ignored by cron.
The cron program invokes a subshell from your $HOME directory. It will not run your
.profile file. If you schedule a command to run when you are not logged in and you want
to have commands in your .profile run, you must explicitly do so in the crontab file.
(For a more detailed discussion of how you can invoke sh, see the sh command.)
Environment Variables
The cron program supplies a default environment for every shell, defining HOME, LOGNAME,
SHELL (=/bin/sh), and PATH (=:/bin:/bin/unsupported:/usr/bin).
This command supports the use of the EDITOR, LANG, LC_ALL, LC_CTYPE,
LC_MESSAGES, and NLSPATH environment variables.
EXAMPLES
The following examples show valid crontab file entries.
a. To write the time to the file every hour on the hour, enter:
0****echo The hour is ‘date‘. >/datefile
This example uses command substitution. (For more information, see the sh
command.)
b. To run cal at 6:30 a.m. every Monday, Wednesday, and Friday, enter:
30 6 * * 1,3,5 cal > /calfile
c. To define text for the standard input file to a command, enter:
0 16 10-31 12 5 wall %HAPPY HOLIDAYS% Drive safely%
This writes a message at 4:00 p.m. each Friday between December 10 and 31 to
all users logged in.
The text following the first % (percent sign) defines the standard input file to the
2112 Hewlett-Packard Company 527188-021