Encyclopedia > Crontab (Unix command)

  Article Content

Crontab

Redirected from Crontab (Unix command)

Table of contents

The crontab command

The crontab command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically at particular times. It reads a series of commands from standard input and collects them into a file known also known as a "crontab" which is later read and whose instructions are carried out.

Generally, crontab uses a daemon, crond, which runs constantly in the background and checks once a minute to see if any of the scheduled jobs need to be executed. If so, it executes them.

Crontab files

The crontab files are where the lists of jobs and other instructions to the cron daemon are kept. Users can have their own individual crontab files and often there is a systemwide crontab file (usually in /etc or a subdirectory of /etc) which is also used but can only be edited by the system administrator(s).

Crontab files have a particular format. Each line of a crontab file follows a particular format as a series of fields, separated by spaces and/or tabs. Each field can have a single value or a series of values.

Operators

There are several ways of specifying multiple values in a field:
  • The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
  • The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"
  • The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour'.

There is also an operator which some extended versions of cron support, the slash ('/') operator, which can be used to skip a given number of values. For example, "*/3" in the hour time field is equivalent to "0,3,6,9,12,15,18,21"; "*" specifies 'every hour' but the "/3" means that only the first, fourth, seventh...and such values given by "*" are used.

Fields

The first five fields of the line are the date and time field which specify how frequently and when to execute a command.

Field no. Description Permitted values
1 minute 0-59
2 hour 0-23
3 day of the month 1-31
4 month 1-12
5 day of the week 0-7

The sixth and subsequent fields (i.e. the rest of the line) specify the command to be run.

See also

  • at (runs scheduled tasks at regular intervals)



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Westhampton Beach, New York

... under the age of 18 living with them, 47.1% are married couples living together, 11.1% have a female householder with no husband present, and 38.1% are non-families ...

 
 
 
This page was created in 30.9 ms