Name
crontab — stdin stdout - file -- opt --help --version
Synopsis
crontab [options] [file]
The crontab command, like
at, schedules jobs for specific
times. However, crontab is for
recurring jobs, such as “Run this command at midnight on the second
Tuesday of each month.” To make this work, you edit and save a file
(called your crontab file), which
automatically gets installed in a system directory (/var/spool/cron). Once a minute, a Linux
process called cron wakes up,
checks your crontab file, and executes any jobs that are
due.
-
$ crontab -e Edit your crontab file in your default editor (
$EDITOR)-
$ crontab -l Print your crontab file on standard output
-
$ crontab -r Delete your crontab file
-
$ crontab myfile Install the file myfile as your crontab file
The superuser can add the option -u username to
work with other users’ crontab files.
Crontab files contain one job per line. (Blank lines and
comment lines beginning with “#” are ignored.)
Each line has six fields, separated by whitespace. The first five
fields specify the time to run the job, and the last is the job
command itself.
- Minutes of the hour
Integers between 0 and 59. This can be a single number (
30), a sequence of numbers separated by commas (0,15,30,45), a range (20–30), a sequence of ranges (0-15,50-59), or an asterisk to mean “all.” You can also specify “everynth time” with the suffix/n; for instance, both*/12and0-59/12mean0,12,24,36,48(i.e., every 12 minutes).- Hours of the day
Same syntax as for minutes.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access