A quick syntax reference for the UNIX cron daemon schedule format and crontab management utilities.
Cron Schedule Expression Format
Standard cron expressions consist of 5 space-delimited time and date fields:
┌───────────── Minute (0 - 59)
│ ┌─────────── Hour (0 - 23)
│ │ ┌───────── Day of Month (1 - 31)
│ │ │ ┌─────── Month (1 - 12 or JAN - DEC)
│ │ │ │ ┌───── Day of Week (0 - 6, 0 = Sunday or SUN - SAT)
│ │ │ │ │
* * * * * command_to_execute
Special Characters & Operators
| Operator | Meaning | Example |
|---|---|---|
* |
Any value / every interval | * * * * * (Every minute) |
, |
Value list separator | 15,45 * * * * (Minutes 15 and 45) |
- |
Range of values | 0 9-17 * * * (Hourly between 9 AM and 5 PM) |
/ |
Step values | */10 * * * * (Every 10 minutes) |
Predefined Shorthand Strings
| String | Equivalent Expression | Meaning |
|---|---|---|
@reboot |
Run once at startup | Run command upon system reboot |
@hourly |
0 * * * * |
Once an hour at minute 0 |
@daily / @midnight |
0 0 * * * |
Once a day at midnight |
@weekly |
0 0 * * 0 |
Once a week on Sunday midnight |
@monthly |
0 0 1 * * |
Once a month on the 1st at midnight |
@yearly / @annually |
0 0 1 1 * |
Once a year on Jan 1st at midnight |
Common Schedule Examples
| Expression | Schedule |
|---|---|
*/15 * * * * |
Every 15 minutes |
0 */2 * * * |
Every 2 hours on the hour |
0 18 * * 1-5 |
Every weekday at 6:00 PM |
30 2 * * 0 |
Every Sunday at 2:30 AM |
0 0 1,15 * * |
1st and 15th of every month at midnight |
Crontab Management Commands
# Edit active crontab in default text editor
crontab -e
# View / list existing cron jobs
crontab -l
# Remove / wipe all current cron jobs
crontab -r
# Manage crontab for a specific user (requires root/sudo)
crontab -u www-data -l
crontab -u www-data -e