...
| Info |
|---|
If you have cPanel, cron jobs can be managed directly in your control panel without directly modifying a crontab. See cPanel's Cron Jobs Featureen cPanel [Como configurarlos] for more information. |
| Table of Contents |
|---|
...
| Code Block | ||
|---|---|---|
| ||
┌───────────── minute │ ┌───────────── hour │ │ ┌───────────── day of the month │ │ │ ┌───────────── month │ │ │ │ ┌───────────── day of the week │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * * * * * |
Above diagram courtesy of Wikipedia.
| Field | Accepted Values |
|---|---|
| minute | 0-59 |
| hour | 0-23 |
| day of the month | 1-31 |
| month | 1-12 or names (see below) |
| day of the week | 0-7 (Sunday is 0 or 7) or names |
Cron jobs are run whenever the minute , hour , and month fields match the current time, and when at least one of the day of the month , or day of the year fields matches.Names for days of the week, or months are the first three letters of a day or month (e.g Mon for Monday, Oct for October).
...
There are a handful of special time shorthand that may be used instead of the five date and time fields.
| Shorthand | Value |
|---|---|
@reboot | Runs once after a reboot. |
@yearly or @annually | Run once a year (0 0 1 1 *). |
@monthly | Run once a month (0 0 1 * *). |
@weekly | Run once a week (0 0 * * 0). |
@daily | Run once a day (0 0 * * *). |
@hourly | Run once an hour (0 * * * *). |
Examples
A command that runs every minute:
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
0,10,20,30,40,50 * * * * /path/to/command |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
*/6 * * * * /path/to/command |
...
| Code Block | ||
|---|---|---|
| ||
Hourly message. Hourly message. Hourly message. |
If you don't care about the normal output of a cron job, and only want to be notified when it encountered an error, you can redirect the output to /dev/null.
...