- Home
- Tools
- Developer Tools
- Cron Expression Explainer
- Cron Expression for Every Weekday
Cron Expression for Every Weekday
0 9 * * 1-5 runs a job at 09:00 from Monday to Friday. Change the hour below, and see why the day-of-month field has to stay a star.
At 09:00 on Monday to Friday
| Field | Value | Matches |
|---|---|---|
| Minute | 0 | 0 |
| Hour | 9 | 9 |
| Day of month | * | every day of the month |
| Month | * | every month |
| Day of week | 1-5 | Monday to Friday |
Next 10 runs
Cron goes by the clock of the machine it runs on. These are the runs on a machine in your time zone.
Monday to Friday
In 0 9 * * 1-5 the last field does the work: 1-5 is Monday to Friday. The names say the same, MON-FRI, and are harder to get wrong. The 9 is the hour, so this runs at 09:00. For another time, change the first two fields.
| Expression | Runs |
|---|---|
| 0 9 * * 1-5 | At 09:00 on Monday to Friday |
| 0 9 * * MON-FRI | At 09:00 on Monday to Friday |
| 0 9,17 * * 1-5 | At 09:00 and 17:00 on Monday to Friday |
| 0 9-17 * * 1-5 | Every hour from 09:00 to 17:00 on Monday to Friday |
| 0 9 * * 6,0 | At 09:00 on Saturday and Sunday |
| 0 9 1 * 1-5 | At 09:00 on the 1st of the month and on Monday to Friday |
Leave the third field alone
It is tempting to combine the weekdays with a date, as in the last row of the table: "at 09:00 on the 1st, if that is a working day". Cron reads it the other way. When day of month and day of week are both filled in, a match on either one is enough, so 0 9 1 * 1-5 runs on every weekday and also on the 1st when that is a Saturday.
What cron doesn't know
Public holidays. The job runs on Christmas Day if that is a Tuesday. If that matters, the script has to check the date itself.
Where the working week runs from Sunday to Thursday, the range is 0-4. In a crontab 0 is Sunday and 1 is Monday. Quartz counts differently, there 1 is Sunday, so use the names when an expression has to work in both.
The cron expression explainer has the full syntax: the five fields, lists, ranges and steps, and how day of month and day of week work together.