Reading a cron schedule
Cron is the job scheduler built into Linux and macOS, and its syntax is used by many other systems too: GitHub Actions, Kubernetes CronJobs, cloud schedulers and most job queues. A single line tells it when to run a command. The syntax is compact and easy to get wrong, and a typo can mean a backup runs every minute instead of every month. Build the schedule with the presets, or paste an existing expression to see what it really does and when it will next run.
The five fields
┌───────────── minute (0–59)
│ ┌─────────── hour (0–23)
│ │ ┌───────── day of month (1–31)
│ │ │ ┌─────── month (1–12 or JAN–DEC)
│ │ │ │ ┌───── day of week (0–6 or SUN–SAT, 7 is also Sunday)
│ │ │ │ │
* * * * * command to runSpecial characters
*matches every value.,separates a list:1,15in the day field means the 1st and 15th.-defines a range:9-17in the hour field means 9 a.m. through 5 p.m./sets a step:*/15in the minute field means every 15 minutes, and9-17/2means every second hour from 9 to 17.
Common examples
| Expression | Meaning |
|---|---|
*/5 * * * * | Every 5 minutes |
0 * * * * | Every hour, on the hour |
0 0 * * * | Every day at midnight |
30 9 * * 1-5 | At 09:30 on weekdays |
0 0 * * 0 | Every Sunday at midnight |
0 3 1 * * | At 03:00 on the 1st of each month |
0 0 1 1 * | Once a year, on 1 January |
Shortcuts
Most cron implementations accept @hourly, @daily (or @midnight), @weekly, @monthly and @yearly (or @annually) in place of the five fields, plus @reboot to run once at startup. You can type these into the box above.
Gotchas
- Day of month and day of week: if both fields are restricted, cron runs when either one matches.
0 0 13 * 5runs on every 13th and on every Friday, not only on Friday the 13th. - Time zones: cron uses the server's time zone, which is often UTC. Check before scheduling anything for a specific local time.
- Daylight saving: jobs scheduled in the hour that is skipped or repeated when clocks change may run zero times or twice, depending on the implementation.
- Short months:
0 0 31 * *only runs in months with 31 days. There is no "last day of the month" in standard cron. - Seconds: standard cron has no seconds field. Quartz and some other schedulers use six or seven fields, so check which format your system expects.