- Home
- Tools
- Developer Tools
- Cron Expression Explainer
Cron Expression Explainer
Translate a cron schedule into plain English and see when it runs next.
At 09:30 on Monday to Friday
| Field | Value | Matches |
|---|---|---|
| Minute | 30 | 30 |
| Hour | 9 | 9 |
| Day of month | * | every day of the month |
| Month | * | every month |
| Day of week | 1-5 | Monday to Friday |
Next 10 runs
Cron goes by the clock of the machine it runs on. These are the runs on a machine in your time zone.
The five fields
A cron expression is five fields separated by spaces. The job runs in every minute in which all five agree with the clock.
| Field | Allowed values | Remarks |
|---|---|---|
| Minute | 0-59 | |
| Hour | 0-23 | 0 is midnight |
| Day of month | 1-31 | |
| Month | 1-12 or JAN-DEC | |
| Day of week | 0-7 or SUN-SAT | 0 and 7 are both Sunday |
30 9 * * 1-5 reads as minute 30, hour 9, any day of the month, any month, Monday to Friday: 09:30 on working days.
Inside a field you can write:
| Syntax | Meaning | Example |
|---|---|---|
* | every value | * as hour: every hour |
a,b | a list | 0,30 as minute: on the hour and at half past |
a-b | a range, both ends included | 9-17 as hour |
*/n | every nth value, counted from the lowest | */15 as minute: 0, 15, 30 and 45 |
a-b/n | every nth value within a range | 10-40/5 as minute: 10, 15, 20 up to 40 |
Two classic traps
A step starts again with every hour, day or month. */7 in the minute field is not "every seven minutes". It is minutes 0, 7, 14 and so on up to 56, and then minute 0 again, four minutes later. Only steps that divide the range evenly give a steady rhythm: for minutes those are 2, 3, 4, 5, 6, 10, 12, 15, 20 and 30. In the same way */2 as day of month runs on the 31st and again on the 1st.
Day of month and day of week are joined by "or". 0 0 13 * 5 is not Friday the 13th. When both fields are restricted, the job runs when either one matches: on every 13th and on every Friday. The expression has no way to ask for both. The usual way round it is to schedule one of them and test the other in the command:
0 0 13 * * [ "$(date +\%u)" = 5 ] && /path/to/job
The backslash is needed because cron treats a bare % in a command as a line break.
There is one exception. Vixie cron and its successor cronie, which most Linux distributions use, count a day field that starts with * as unrestricted. 0 0 */2 * 1 therefore runs on odd dates that are also Mondays. This page follows that rule.
Time zones and daylight saving
Cron compares the fields with the local clock of the machine it runs on. On a server set to UTC, 0 9 * * * fires at 09:00 UTC, which is 10:00 in Amsterdam in winter and 11:00 in summer. The list of next runs can be worked out for your own time zone or for UTC.
Where the clocks change for daylight saving, an hour of one night in spring does not exist, and a job scheduled in it is skipped. In autumn an hour comes round twice and the job runs twice. That is what a cron that simply checks the clock does, and it is what the list on this page shows. cronie softens this for jobs with a fixed time: those from the skipped hour run straight after the change, and those in the repeated hour run once. Jobs that run every hour or more often are not adjusted. If the exact moment matters, keep such jobs out of the small hours or run the server on UTC.
What this page reads
- Five fields, or six with a seconds field in front, as Quartz and Spring write them. A system crontab has no seconds.
- The shortcuts
@hourly,@dailyor@midnight,@weekly,@monthly,@yearlyor@annually, and@reboot. - A whole line from a crontab. What follows the schedule is shown as the command.
?, which Quartz wants in one of the two day fields, is read as*.
The other Quartz extensions are not supported: L (last), W (nearest working day), # (the nth weekday of the month) and a seventh field for the year. Check the weekday numbers when you paste a Quartz expression: Quartz counts from 1 for Sunday to 7 for Saturday, while crontab and this page use 0 or 7 for Sunday and 1 for Monday. Names such as MON mean the same in both.
Two things that other schedulers accept are errors here, as they are in a crontab: a range that wraps around (22-2, write 22-23,0-2) and a step without a range in front (5/15). The ~ of cronie, which picks a random value, is refused because it has no fixed time to show.