crontab - schedule periodic background work


crontab [ options ] [ file ]


crontab creates, replaces or edits the calling user crontab entry; a crontab entry is a list of commands and the times at which they are to be executed. The new crontab entry can be input by specifying file, or input from standard input if file is omitted, or by using an editor, if --edit is specified. The actual crontab entry is maintained in the file $HOME/.crontab.

Upon execution of a command from a crontab entry, the implementation will supply a default environment, defining at least the following environment variables:

A pathname of the calling user home directory.

The calling user login name.
A string representing a search path guaranteed to find all of the standard utilities.

A pathname of the command interpreter sh(1).

If standard output and standard error are not redirected by commands executed from the crontab entry, any generated output or errors will be mailed to the calling user.

Users are permitted to use crontab if their names appear in the file /usr/lib/cron/cron.allow. If that file does not exist, the file /usr/lib/cron/cron.deny is checked to determine if the calling user should be denied access to crontab. If neither file exists, only a process with appropriate privileges is allowed to submit a job. If only cron.deny exists and is empty, global usage is permitted. The cron.allow and cron.deny files consist of one user name per line.

In this implementation, each command in the crontab file represents a single at(1) job. Only one job per command will be executed. A new job for a given command will not be scheduled until the previous job for that command, if any, has exited.


-e, --edit

Edit a copy of the calling user crontab entry, or create an empty entry to edit if the crontab entry does not exist. When editing is complete, the entry will be installed as the calling user crontab entry. The editor used is defined by the EDITOR environment variable. The default editor is vi(1).
-l, --list

List the calling user crontab entry.
-r, --remove|delete

Remove the calling user crontab entry.


A crontab entry must be a text file consisting of lines of six fields each. The fields must be separated by blank characters. The first five fields must be integer patterns that specify the following:
Minute (0-59)
Hour (0-23)
Day of the month (1-31)
Month of the year (1-12)
Day of the week (0-6 with 0=Sunday)

Each of these patterns can be either an asterisk (meaning all valid values), an element or a list of elements separated by commas. An element must be either a number or two numbers separated by a hyphen (meaning an inclusive range). The specification of days can be made by two fields (day of the month and day of the week). If month, day of month and day of week are all asterisks, every day will be matched. If either the month or day of month is specified as an element or list, but the day of week is an asterisk, the month and day of month fields will specify the days that match. If both month and day of month are specified as asterisk, but day of week is an element or list, then only the specified days of the week will match. Finally, if either the month or day of month is specified as an element or list, and the day of week is also specified as an element or list, then any day matching either the month and day of month or the day of week, will be matched.

The sixth field of a line in a crontab entry is a string that will be executed by sh at the specified times. A percent sign character in this field will be translated to a newline character. Any character preceded by a backslash (including the %) causes that character to be treated literally. Only the first line (up to a "%" or end-of-line) of the command field will be executed by the command interpreter. The other lines will be made available to the command as standard input.

A job label is generated by a readable hash of the command. If the first characters are : label; then the job label will be set to label verbatim. Job labels are limited to 12 characters.

Blank lines and those whose first non-blank character is "#" will be ignored.



Edited per-user crontab entry file.


at(1), batch(1), sh(1)



crontab (AT&T Labs Research) 2006-05-17

Glenn Fowler < >

Copyright © 1996-2012 AT&T Intellectual Property