Basics of the crontab ∞
Crontab file controls how and what to run by cron. The crontab line has a format as follows:
.---------------- 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 ...
| | | | |
* * * * * command to be executed
To add a cron job for your current user, run
$ crontab -e
use crontab extensions ∞
crontab provides some extensions to support this: ranges can include “steps” like /2
. 1-9/2
is the same as 1,3,5,7,9
. This can be the easiest method if the job is intended to be run every two N in a range such as N is “day” and the range is “days in a month”. Check the crontab man page for more details about ranges and steps of crontab.
An example.
To run the command every two months at 1:00 on the first day of the month, the crontab is
0 1 1 */2 * command to be executed
No comments:
Post a Comment