Cron every weekday: 0 0 * * 1-5
0 0 * * 1-5 runs at midnight on Monday, Tuesday, Wednesday, Thursday and Friday, five times a week and about 261 times a year.
At a glance
- Expression
- 0 0 * * 1-5
- Fires
- 5 times a week, about 261 times a year.
- Restricted fields
- Day of week restricted to 1-5, minute and hour pinned. Day of month and month are open.
- Equivalent macro
- None. @weekly is Sunday only and cannot express a set of days.
- Day numbers
- 1 is Monday through to 5 is Friday. 0 is Sunday and 6 is Saturday.
- Alias form
- MON-FRI is accepted and is case insensitive, so mon-fri works too.
In detail
The day of week field numbers Sunday as 0, so the working week is 1 through 5 and the range covers it in one token. Because the day of month field is left open, only the weekday restriction applies, which is the straightforward case: the job runs on exactly the five days named and no others.
Names are usually clearer than numbers here. MON-FRI matches the same five days and does not require the reader to remember which end of the week is zero. The parser accepts month and weekday names in any case, and they can be used at either end of a range, so mon-FRI is legal even though writing it that way helps nobody.
Midnight is a defensible default for a weekday job that prepares something for the morning, but it means the Monday run happens at 00:00 on Monday, before anyone has done any work that week. If the job summarises the previous working day, the Monday run covers Sunday and will find nothing. That is usually a sign the intended schedule was Tuesday through Saturday, or that the job should look back to the previous weekday rather than the previous day.
Cron has no concept of a public holiday, so this expression runs on every bank holiday, every company shutdown day and Christmas Day when it falls on a weekday. If that matters, the check belongs in the script: a file of dates and a single test at the top costs almost nothing and is far more maintainable than trying to encode holidays in the expression.
Examples
0 0 * * 1-50 0 * * MON-FRI0 0 * * 1-5 grep -qx "$(date +\%Y-\%m-\%d)" /etc/app/holidays.txt || /opt/app/bin/daily.shThe percent signs are escaped because cron turns an unescaped % into a newline.
Things that catch people out
- Adding a day of month restriction changes the logic completely. 0 0 1-7 * 1-5 fires on days 1 to 7 and on every weekday, because the two date fields are combined with OR.
- Percent signs in a crontab command must be escaped with a backslash. An unescaped one ends the command and feeds the rest to it on standard input.
- 1-5 is Monday to Friday only if you remember Sunday is 0. If you think of Monday as day 0, everything shifts by one and the job runs Sunday to Thursday.
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 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.
Cron every day except Sunday: 0 0 * * 1-6
Cron has no not operator, so excluding a day means listing the six you want. 0 0 * * 1-6 covers Monday through Saturday, six runs a week.
The cron day of week field: 0 to 7 with Sunday at both ends
The day of week field runs 0 to 7 with Sunday as both 0 and 7, and accepts SUN through SAT. Restricting it changes how the day of month field behaves.
Cron during business hours: 0 9-17 * * 1-5
0 9-17 * * 1-5 runs hourly from 09:00 to 17:00 on weekdays, nine times a day and 45 times a week. The 17:00 run is included, not excluded.
Cron every Monday at 9 AM: 0 9 * * 1
0 9 * * 1 runs at 09:00 every Monday, 52 or 53 times a year. Day 1 is Monday, and the fifth field is the only one that needs to change.
Cron every Sunday at midnight: 0 0 * * 0 and @weekly
0 0 * * 0 runs at midnight every Sunday and is exactly what @weekly expands to. Sunday is both 0 and 7 in the day of week field.
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