cron Table Fields Reference
These lists and examples describe how cron jobs can be
configured.
The contents of the /etc/crontab configuration file consist of
definitions for the SHELL, PATH, MAILTO,
and HOME variables for the environment in which the jobs run. These
definitions are then followed by the job definitions themselves. Comment lines start with a
# character.
All jobs in the /etc/crontab file are run as the root
user, unless otherwise specified.
A /etc/crontab file without any configured job appears as follows:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
Job definitions consist of information that you specify in the appropriate fields as follows:
- Minute
- The minute part of the schedule. (0 to 59)
- Hour
- The hour part of the schedule. (0 to 23)
- Day
- The calendar day part of the schedule. (1 to 31)
- Month
- The calendar month part of the schedule. (1 to 12)
- Day of the week
- The weekday part of the schedule. (0 to 7, or
sun,mon,tue, and so on. Sunday is 0 or 7) - Username
- User account running the job. For example,
jsmith. Specifying an asterisk (*) runs the job as the owner of thecrontabfile. - Command
- The shell script or command to be run. For example,
example.sh.
For the minute through day-of week fields, you can use the following special characters:
-
* - Specify an asterisk (
*) to run thecronjob for all valid intervals in the field. -
- - Specify a dash (
-) to indicate a range of integers. For example,1-5. -
, - Specify a list of values, separated by commands (
,). For example,0,2,4. -
/ - Specify a step value by using the slash (
/). For example,/3in the hour field. This entry is interpreted as every three hours.
For example, the following entry would run a command every five minutes on weekdays:
0-59/5 * * * 1-5 * command
To run a command at one minute past midnight on the first day of the months April, June, September, and November, add this line:
1 0 1 4,6,9,11 * * command
Note:
If you add a job file to the /etc/cron.hourly directory,
crond runs the job every hour.
For more information, see the crontab(5) manual page.