The expression
0 0 * * 1-5
Runs at midnight (00:00) at the start of Monday, Tuesday, Wednesday, Thursday and Friday. It does not run at the start of Saturday or Sunday.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 |
at minute 0 |
| Hour | 0 |
at midnight |
| Day of month | * |
any day |
| Month | * |
every month |
| Day of week | 1-5 |
Monday (1) to Friday (5) |
The weekday part is all in the last field. 1-5 is a range; MON-FRI means the same in most implementations. Sunday is 0 (and also 7), Saturday is 6. Change the first two fields to pick the time of day: the day-of-week field only decides which days.
Variants
| Schedule | Expression |
|---|---|
| Weekdays at 9am | 0 9 * * 1-5 |
| Weekdays at 6pm | 0 18 * * 1-5 |
| Every hour on weekdays, 9 to 5 | 0 9-17 * * 1-5 |
| Every 30 minutes on weekdays | */30 * * * 1-5 |
| Weekends only | 0 0 * * 6,0 |
| Tuesday to Saturday (to process the previous weekday) | 0 0 * * 2-6 |
The last row matters more than it looks. A job at 00:00 on Monday runs at the start of Monday, so if it processes "yesterday" it processes Sunday. For a nightly job that covers each business day, run it at the end of the day (55 23 * * 1-5) or the morning after (0 0 * * 2-6).
Where to write it
- crontab (Linux, macOS):
0 0 * * 1-5 /usr/local/bin/sync.shincrontab -e, in the server's time zone (CRON_TZ=sets another one on systems that support it). - GitHub Actions:
on: schedule: - cron: '0 0 * * 1-5'. GitHub runs it at 00:00 UTC, which is still Sunday evening in the Americas: the "weekday" is a UTC weekday. Shift the hour if the boundary matters. Midnight UTC is also one of the busiest times for scheduled workflows, so expect delays. - Kubernetes CronJob:
schedule: "0 0 * * 1-5"withtimeZone:to choose whose Monday it is. - AWS EventBridge:
cron(0 0 ? * MON-FRI *). The day-of-month field must be?, and EventBridge numbers days 1 (Sunday) to 7 (Saturday), so names are safer than numbers.
Common mistakes
* * * * 1-5runs every minute. The day-of-week field limits the days; it doesn't make the job run once a day. Set minute and hour.- Writing
1-5in AWS. In EventBridge and Quartz,1-5is Sunday to Thursday. - Restricting the day of month too.
0 0 1-7 * 1-5runs on the 1st to the 7th and on every weekday, because cron ORs the two day fields when both are set.
Check it in the Cron Expression Parser to see the next five runs.