A report that lands on Saturday morning helps nobody. A cleanup job that runs on Sunday wastes resources and muddies logs on the two days nobody is watching. Plenty of scheduled work only makes sense inside the working week, and cron can express that restriction in a single field, as long as you get the day numbering right.
The whole schedule is 0 9 * * 1-5, built with the free Cron Expression Builder on Ovatly. This guide reads that expression field by field, explains why the range is 1-5, and covers the one standard cron behaviour that silently undoes a weekday restriction.
Contents
- Quick answer
- Reading the expression field by field
- Why the range is 1-5: the Sunday trap
- How to build and check the schedule, step by step
- Worked example: a weekday report at 09:00
- The either-match warning
- Limitations and honest notes
- Common mistakes
- FAQs
- Conclusion
Quick answer
To run a cron job only on weekdays, restrict the last field, day of week, to the range 1-5 and leave the day-of-month field as an asterisk. At 09:00 the expression is:
0 9 * * 1-5
Minute 0 and hour 9 set the time of day. Day of month and month are asterisks, meaning every value matches. The range 1-5 in the day-of-week field is what does the work: 1 is Monday and 5 is Friday, so the job fires Monday to Friday and skips Saturday and Sunday completely. Change the first two fields to move the time; the 1-5 stays the same for any weekday-only schedule.
Reading the expression field by field
A standard cron expression has five fields in a fixed order: minute (0-59), hour (0-23), day of month (1-31), month (1-12) and day of week (0-7). Reading 0 9 * * 1-5 in that order:
- Minute: 0. The job fires on the hour, not at some point during it.
- Hour: 9. Combined with minute 0, the firing time is 09:00.
- Day of month: asterisk. Every day of the month matches. This field deliberately carries no restriction, for reasons covered below.
- Month: asterisk. Every month matches, so the schedule runs all year.
- Day of week: 1-5. Only Monday, Tuesday, Wednesday, Thursday and Friday match.
The principle is the same as for any schedule: pin the fields that carry the restriction, leave the rest open. Here the restriction lives entirely in the last field.
Why the range is 1-5: the Sunday trap
The range looks off by one to most people, because the day-of-week field does not start its week on Monday. It uses the standard numbering where 0 and 7 both mean Sunday, 1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thursday, 5 is Friday and 6 is Saturday.
That numbering produces two traps:
0-5is not the working week. It runs from Sunday (0) through Friday (5), so the job fires on Sunday and skips Saturday: a five-day range, just the wrong five days.1-7is the whole week. It starts at Monday (1) and ends at Sunday (7), so it covers all seven days and restricts nothing at all.
Only 1-5 lands exactly on Monday to Friday. The double numbering of Sunday is why both wrong versions exist, so check any inherited weekday expression for exactly this mistake.
How to build and check the schedule, step by step
- Open the Cron Expression Builder and choose the pattern "Weekdays (Mon to Fri) at a set time" from the list.
- Set the hour and minute, for example hour 9 and minute 0.
- Read the generated expression and its plain-English description. The builder describes
0 9 * * 1-5as "At 09:00, Monday to Friday". - Check the next five run times listed below the expression. They are shown in your local time zone, and the weekend gap should be visible in the dates.
- To check an expression you already have, paste it into the lower field instead. The builder explains it back to you in plain English, which is the fastest way to catch a
0-5written by someone else.
Worked example: a weekday report at 09:00
Suppose a team wants a summary report generated at 09:00 on working days only. Choosing the weekday pattern with hour 9 and minute 0 produces 0 9 * * 1-5, described as "At 09:00, Monday to Friday".
The next-run list proves the restriction rather than just claiming it. Run the builder on a Friday and the listed runs step from Friday 09:00 directly to Monday 09:00, then Tuesday, Wednesday and Thursday. Saturday and Sunday never appear. If a Saturday run did show up, a range of 0-5 or 1-7 in place of 1-5 would be the usual cause.
To move the report to 08:30, only the first two fields change, giving 30 8 * * 1-5. The weekday restriction is untouched, because it never lived in the time fields.
The either-match warning
One standard cron behaviour can quietly bring the weekends back. When both the day-of-month and day-of-week fields are restricted, a day matches if either field matches, not only when both do.
Say you add a day of month to the weekday expression, producing 0 9 1 * 1-5, intending "weekdays, and also the 1st". What you actually get is every weekday, plus the 1st of every month, including a 1st that falls on a Saturday or a Sunday. The schedule got wider, not narrower, and the extra runs land on exactly the days the original expression was built to avoid.
The rule for a clean weekday schedule is simple: restrict the day-of-week field and keep the day-of-month field as an asterisk. If a job needs both a monthly date and a weekday pattern, those are usually two separate jobs.
Limitations and honest notes
The builder covers standard five-field cron only: minute, hour, day of month, month, day of week. Seconds and year fields from Quartz-style schedulers are not included, so a weekday expression written for those systems needs its extra fields removed before it makes sense here.
Next run times are calculated in your browser's local time. Servers usually run cron in UTC, so the 09:00 in the expression is 09:00 in the scheduler's time zone, which may not be yours. The days shift with the zone too: 09:00 UTC on a Monday can still be Sunday evening in a zone far enough behind UTC.
The expression also knows nothing about public holidays. A weekday schedule fires on a holiday Monday exactly as on any other Monday; handling holidays is a job for the script itself, not the cron fields.
Common mistakes
- Writing
0-5for the working week. That range starts on Sunday. The working week is1-5. - Writing
1-7and thinking it means weekdays. Because 7 is Sunday, that range covers all seven days. - Restricting both day fields. A day-of-month value next to a day-of-week range triggers the either-match behaviour and reintroduces weekend runs.
- Putting the range in the wrong field. A
1-5in the day-of-month field means the first five days of the month, every month, weekends included. - Trusting the on-screen clock for a UTC server. The builder lists run times in your local zone; the server may fire hours earlier or later.
FAQs
What is the cron expression for a job that runs only on weekdays?
For 09:00 Monday to Friday it is 0 9 * * 1-5. The minute and hour fields set the time, and the range 1-5 in the day-of-week field limits the days to Monday through Friday.
Why does 1-5 mean Monday to Friday?
Day-of-week numbering runs from Sunday. Both 0 and 7 mean Sunday, 1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thursday, 5 is Friday and 6 is Saturday. The range 1-5 therefore covers Monday to Friday and nothing else.
Can I write the weekday range as 0-5 or 1-7 instead?
No. The range 0-5 includes Sunday and drops Saturday, and 1-7 runs from Monday through Sunday because 7 is Sunday again. Both fire on days you meant to skip. Only 1-5 is the working week.
What happens if I also set a day of month? Under standard cron behaviour, when both the day-of-month and day-of-week fields are restricted, a day matches if either field matches. A job set for the 1st of the month and weekdays would fire on the 1st even when the 1st falls on a Saturday. Keep day of month as an asterisk for a pure weekday schedule.
Why did my weekday job fire at the wrong clock time?
The builder lists next run times in your local time zone, but most servers schedule in UTC. The expression 0 9 * * 1-5 fires at 09:00 in whatever time zone the scheduler uses, which may be several hours away from 09:00 where you are.
Conclusion
A weekday-only schedule is a one-field decision: 1-5 in the day-of-week field, an asterisk in the day-of-month field, and whatever minute and hour the job needs. Build it in the Cron Expression Builder, confirm the weekend gap in the next-run list, and watch out for inherited expressions carrying 0-5 or 1-7 instead. If the field order and operators behind the range are still fuzzy, the companion guide Cron Syntax Explained walks through all five fields one at a time, and the full set of guides for this category lives in the Developer Tools guides archive.