Cron step values: what */n really does
A step walks a field from its lowest allowed value upwards in increments of n. It never means every n units from now, and it never continues past the end of the field.
At a glance
- Meaning
- Match every nth value, counting from the start of the range.
- Starting point
- The field minimum: 0 for seconds, minutes, hours and day of week, 1 for day of month and month.
- Step of 1
- Identical to an asterisk. */1 matches every value.
- Step larger than the range
- Matches only the first value. */90 in the minute field gives minute 0 alone.
- Applies to
- An asterisk or a range. */5 and 0-30/5 are both valid.
- Minimum value
- 1. A step of 0 is rejected.
In detail
A step is a filter over a set of candidate values, not an interval measured from the moment the job was installed. The parser takes the range the step applies to, starts at its lowest value and adds n repeatedly until it passes the top. Everything it lands on matches, and everything else does not.
Because the walk starts at the field minimum, the same step gives different results in different fields. */2 in the minute field starts at 0 and gives even minutes. */2 in the day of month field starts at 1 and gives odd numbered days. Neither is a bug; the fields simply have different lower bounds.
The step also stops at the end of the field, which means it does not divide the range evenly unless n is a divisor. */7 in the minute field gives 0, 7, 14, 21, 28, 35, 42, 49 and 56, and then the next match is minute 0 of the following hour, four minutes later rather than seven. Every step that is not a divisor of 60, or of 24 in the hour field, has an irregular gap at the boundary.
Finally, a step never carries a phase of its own. There is no way to write a plain step that starts anywhere other than the field minimum, which is what the start at step form exists for. If you need every fifteen minutes offset by seven, the answer is a range with a step or a start at step, not a modified asterisk.
Examples
*/5 * * * *Minutes 0, 5, 10 and so on to 55.
*/7 * * * *Minutes 0, 7, 14, 21, 28, 35, 42, 49, 56. The gap into the next hour is four minutes, not seven.
0 0-20/4 * * *Hours 0, 4, 8, 12, 16 and 20. Nothing after 20:00.
Things that catch people out
- */n is not every n units from now. A crontab installed at 12:03 with */5 first runs at 12:05.
- The starting point is the field minimum, so */2 means even minutes but odd days of the month.
- A step bigger than the field gives exactly one value and no error. */90 in the minute field runs once an hour.
Try it: Cron Expression Parser
Paste any five or six field expression to get a plain English description, a per field breakdown and the next run times in your local time.
Cron Expression Parser
LOCAL · Browser-OnlyParse cron expressions and see the next scheduled run times
Supports 5-field (minute hour day month weekday), 6-field (with seconds), named values (JAN, MON), and @macros (@daily, @hourly, ...)
Use the dropdowns below to build your cron expression visually, or type a custom value in each field.
Human-Readable Description
Every 5 minutes
Field Breakdown
| Field | Allowed | Value | Meaning |
|---|---|---|---|
| Minute | 0-59 | */5 | every 5 minute(s) |
| Hour | 0-23 | * | every hour |
| Day of Month | 1-31 | * | every day of month |
| Month | 1-12 | * | every month |
| Day of Week | 0-7 | * | every day of week |
Related cron expressions
All cron expressions →Cron n/step: starting a step from a value you choose
The form 5/15 means start at 5 and step by 15, giving 5, 20, 35 and 50. It is how you move a repeating job off the crowded top of the hour.
The cron asterisk: what * means in each field
An asterisk matches every value in a field's own range, which differs per field. Why * */1 * * * is every minute and not every hour.
The cron hyphen: inclusive ranges and why they cannot wrap
A hyphen range includes both ends, so 9-17 is nine values. The start must not be greater than the end, which is why 22-6 is rejected.
Cron every 45 minutes: why */45 * * * * does not do it
*/45 * * * * fires at minute 0 and minute 45 only, so the gaps alternate 45 and 15 minutes. Here is the four line crontab that really runs every 45 minutes.
The cron minute field: position, range and behaviour
The minute field runs 0 to 59 and is the first field in a five field expression, or the second when a seconds field is present.
The cron hour field: 0 to 23 on a 24 hour clock
The hour field runs 0 to 23 on a 24 hour clock. Midnight is 0, noon is 12, and 24 is out of range. There is no AM or PM notation.
Tools for this
- Cron Expression Parser Free online cron expression parser - parse cron expressions and see the next scheduled run times
- Crontab Generator Free online crontab generator - build cron expressions visually with an intuitive interface