What it means
| Field | Value | Runs on |
|---|
Next runs
Cron uses the server's time zone, which is often UTC. Check with timedatectl on the server.
Build one
Pick a schedule and the expression above updates.
Days 29 to 31 are skipped in months that don't have them. For the last day of the month, run on days 28 to 31 and check the date in your script.
Crontab line
Run crontab -e, paste the line at the bottom, then save and close. crontab -l lists your jobs. Use full paths, because cron runs with a minimal PATH, and add >> /tmp/job.log 2>&1 to the end to keep the output. See Linux: Scheduled tasks for more.
Common schedules
| Expression | Means | Good for |
|---|---|---|
| Every minute. | Testing a new job | |
| Every 5 minutes. | Health checks and monitoring | |
| Every hour, on the hour. | Hourly syncs | |
| Every 6 hours from midnight, on the hour. | Pulling updates a few times a day | |
| At 02:00, every day. | Nightly backups, outside working hours | |
| At 09:00, Monday to Friday. | Weekday reports | |
| At 03:00, on Sunday. | Weekly maintenance, early Sunday | |
| At 00:00, on the 1st of the month. | Monthly invoices and log rotation | |
| At 04:00, on the 1st of the month, in January, April, July and October. | Quarterly jobs | |
| Once, each time the computer starts up. | Starting something when the server boots |
How it works
A cron expression has five fields, separated by spaces, followed by the command to run:
| Field | Values |
|---|---|
| Minute | 0 to 59 |
| Hour | 0 to 23 |
| Day of the month | 1 to 31 |
| Month | 1 to 12, or jan to dec |
| Day of the week | 0 to 6 from Sunday, or sun to sat. 7 is also Sunday. |
* means every value. 1-5 is a range, 1,15 a list, and */15 every 15th value, so every 15 minutes in the minute field. You can combine them: 0-30/10 is 0, 10, 20 and 30.
If you set both the day of the month and the day of the week, cron runs on either. 0 0 13 * 5 runs on every 13th and every Friday, not only Friday the 13th. If either field starts with *, both have to match.
Shortcuts: @hourly, @daily, @weekly (Sunday at midnight), @monthly, @yearly and @reboot, which runs once at start-up.
Cron runs in the server's time zone. On the night the clocks go forward, a job set for a time that's skipped may run late or not at all, so keep important jobs out of 01:00 to 03:00. GitHub Actions schedules always run in UTC. In a crontab, a % in the command means a new line, so write %.
This tool reads standard Linux cron (cronie and Vixie cron). Quartz, Spring and AWS EventBridge use a different format with seconds, years and ?.