Cron Expression for Every Weekday at 9am
The cron expression for "every weekday at 9am", what each field means, and the next run times on your clock.
What is the cron expression for every weekday? The cron expression for every weekday at 9am is 0 9 * * 1-5. Minute 0 and hour 9 set the time, and 1-5 in the day-of-week field means Monday to Friday, with 0 or 7 for Sunday. Change the 9 for another hour, or use 0 0 * * 1-5 for midnight on weekdays.
0 9 * * 1-5At 09:00 AM, Monday through Friday
- …
- …
- …
- …
- …
Can you write MON-FRI instead of 1-5?
It depends on the cron. The cronie man page says "Ranges and lists of names are allowed", with examples such as mon,wed,fri. The Debian cron man page says the opposite: "Ranges or lists of names are not allowed." The numeric 1-5 works in both, so use it in any crontab that might move between servers.
Other schedulers number the week their own way. AWS EventBridge counts 1 to 7 from Sunday, so its weekday version is 0 9 ? * MON-FRI *, and a numeric 1-5 there would mean Sunday to Thursday. Spring's six-field cron accepts names too: its docs give 0 0 9-17 * * MON-FRI for on the hour, nine to five, on weekdays.
Whose 9am does a weekday cron job run at?
The scheduler's time zone. On a server set to UTC, 0 9 * * 1-5 fires at 09:00 UTC, which is 04:00 in New York in winter and 05:00 in summer. That is fine for a batch job, and wrong for a reminder people should see at the start of their day.
Set the zone where the schedule lives. Cronie reads a CRON_TZ line in the crontab, Kubernetes CronJobs use .spec.timeZone, and GitHub Actions accepts an IANA time zone on the schedule. Cron knows nothing about public holidays, so keep 1-5 and have the script exit early on dates from your own holiday list.
Frequently asked
What does 1-5 mean in a cron expression?
In the day-of-week field, 1-5 means Monday through Friday. Standard cron counts Sunday as 0, and cronie also accepts 7 for Sunday, so the working week is 1 to 5 and the weekend is 6 and 0.
How do I run a cron job only on weekends?
Use 0,6 in the day-of-week field: 0 10 * * 0,6 runs at 10:00 every Saturday and Sunday. Where your cron accepts names, the same field can read SAT,SUN.
Why does 0 9 1 * 1-5 run on more days than the 1st?
When both day fields are set, cron runs if either one matches. The cronie man page gives 30 4 1,15 * 5 as its example, which runs on the 1st and 15th plus every Friday. So 0 9 1 * 1-5 runs on the 1st and on every weekday.