The cron comma: listing several values in one field
A comma separates several values inside one field, and every element may itself be a single value, a range or a step. Spaces are not allowed anywhere in the list.
At a glance
- Meaning
- Match any of the listed values.
- Element types allowed
- A single value, a name where the field supports names, a range, or a range with a step.
- Order
- Irrelevant. The parser sorts the values, so 17,9 and 9,17 are the same field.
- Duplicates
- Collapsed. 1,1,2 matches the same two values as 1,2.
- Spaces
- Not permitted. A space splits the expression into an extra field.
- Empty elements
- Rejected. A trailing or doubled comma reports an empty value in that field.
In detail
The comma is the only operator that lets a field hold values with no arithmetic relationship. Nine and seventeen are not a range and not a step, so 9,17 in the hour field is the only way to say them. Anything a step or a range can express, a list can also express, usually more verbosely and usually more readably.
Each element of the list is parsed independently and can be any single field expression except another list. That means 0-3,5-6 is two ranges, 1,15,20-25 is a value, a value and a range, and 0-30/10,45 is a stepped range plus a value. The results are merged, sorted and deduplicated into one set.
Because the parser sorts, the order you write the list in has no effect on behaviour, only on readability. Writing hours as 9,17 rather than 17,9 costs nothing and makes review faster. The same applies to names: MON,THU reads better than THU,MON and matches identically.
The rule that catches people is whitespace. Cron splits an expression on spaces to find its five or six fields, so a single space after a comma turns one field into two and the whole expression shifts. The error you get is usually about the wrong field entirely, which makes it harder to spot than it should be.
Examples
0 9,12,17 * * *Three runs a day, at 09:00, 12:00 and 17:00.
0 0 * * 0-3,5-6Every day except Thursday.
0-30/10,45 * * * *Minutes 0, 10, 20, 30 and 45. Five runs an hour.
Things that catch people out
- A space after a comma adds a field. 0 9, 17 * * * is six tokens and is read as having a seconds field.
- A trailing comma is an error, not an ignored character. 1,2, reports an empty value.
- Listing the same value twice does not make it run twice. Duplicates are collapsed.
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 →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.
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.
Cron step values: what */n really does
*/n walks a field from its minimum in increments of n. Because it starts at the field minimum, */2 gives even minutes and odd days of the month.
Cron name aliases: JAN to DEC and SUN to SAT
The month and day of week fields accept three letter English names, case insensitively, in single values, ranges, lists and steps.
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 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.
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