The cron day of week field: 0 to 7 with Sunday at both ends
The day of week field accepts 0 through 7, where 0 and 7 both mean Sunday, plus the names SUN through SAT. It is the last field in a five field expression.
At a glance
- Range
- 0 to 7. Both 0 and 7 mean Sunday.
- Position
- Fifth of five fields, or sixth of six.
- Names accepted
- SUN, MON, TUE, THU, FRI, SAT, case insensitively. WED is the one name this parser will not take.
- Numbering
- 0 Sunday, 1 Monday, 2 Tuesday, 3 Wednesday, 4 Thursday, 5 Friday, 6 Saturday.
- Folding
- 7 is converted to 0 before matching, so 0,7 is one day and not two.
- Side effect
- Restricting this field switches the day of month field from AND to OR.
In detail
The week starts on Sunday in this field, which is the convention inherited from the original Unix cron and is not negotiable. Monday is 1, Friday is 5 and Saturday is 6, so the working week is the range 1-5 and the weekend is the list 0,6.
Sunday appears at both ends of the range. The field accepts 7 as well as 0 and folds 7 down to 0 before matching, which exists so that expressions written for schedulers that number Monday to Sunday as 1 to 7 still behave sensibly. The practical consequence is that 0,7 is one day, not two, and that 6-7 is a valid way to write the weekend.
Names are accepted and are usually the better choice. MON-FRI says what it means without requiring the reader to remember where the week starts, and the parser treats it identically to 1-5. There is one gap: the parser screens every field for the Quartz characters L, W, # and ? before it looks up names, so a field containing WED is rejected as though it held a W. Write Wednesday as 3 here.
The important thing about this field is what happens when you restrict it alongside the day of month field. Cron then matches a date if either field matches, so an expression that looks like a narrowing is actually a widening. That rule has its own page, and it is the single most consequential piece of cron behaviour to know.
Examples
0 0 * * 1-5Monday through Friday. MON-FRI is identical.
0 0 * * 0,6Sunday and Saturday. 6-7 matches the same two days.
0 0 * * 0
0 0 * * 7The same schedule. 7 folds to 0.
Things that catch people out
- Sunday is 0, so 1-5 is Monday to Friday. If you assume Monday is 0, everything shifts by a day.
- WED is rejected by this parser. The check for the Quartz W character runs before names are resolved, so Wednesday has to be written as the number 3.
- 0 and 7 are the same day. Listing both does not run the job twice.
- Restricting this field changes the meaning of the day of month field, from an AND to an OR.
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 day of month and day of week: the OR rule
When both date fields are restricted, cron fires if either matches, not both. This turns narrowing expressions into much wider ones without any error.
Cron every weekday: 0 0 * * 1-5
0 0 * * 1-5 runs at midnight Monday through Friday, five times a week. Day numbers, the MON-FRI alias, and why holidays still get a run.
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 at the weekend: 0 0 * * 0,6
0 0 * * 0,6 runs at midnight on Saturday and Sunday, twice a week. Why 6-7 works too, and why 6-0 is rejected as an invalid range.
The cron seconds field: the optional sixth position
A six field expression puts seconds first and shifts everything right. The system crontab has no seconds field, so six fields there means a broken job.
Cron macros: @daily, @weekly, @monthly and the rest
Seven macros expand to ordinary five field expressions, and @reboot has no scheduled time at all. Here is exactly what each one becomes.
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