Cron Fromat Minute,Hour,Date,Month,Day
You can use commas (,) to put more than one time specification in a field. There are other shortcuts, better explained with examples:
- To run a job every hour at 0 and 30 minutes:
0,30 * * * - To run a job at 1AM every Sunday:
0 1 * * Sun - To run a job every five minutes:
0-55/5 * * * * - To run a job the first of January at 4PM:
0 16 1 Jan * - To run a job weekly you can use:
@weekly
which is equivalent to
0 0 * * 0 Here the last 0 means on Sunday. You can also use other special strings: @yearly, @annualy, @daily, @monthly, @midnight, @hourly (see the manual page with man 5 crontab, that is, a manual page in section 5).
Now that we hav a little understanding of times we can use cron. This is called with the command crontab -e to edit your cron jobs. A small warning: this command will put you in an editing mode, calling some default editor. If you do not like the editor (quite likely to be vi) you can change it. For example, to use emacs in a bash shell you can do this:
EDITOR=emacs crontab -e
Once you are in the editing mode you enter your times and the commands to be executed. The commands could be just one simple command, a series of them separated by semicolons (;) or the name of a script. Quitting your editor will save your cron job.
The output of cron, if any, might be mailed to your account. Or you can redirect output to some file (more on this later).
To see what cron jobs are in your account do this:
To delete your cron jobs:
You can use crontab -e to edit existing cron jobs.