Every 2 hours on workdays
Business-hours monitoring without the noise of an hourly job: fires every 2 hours, but only Monday through Friday.
Last updated
In plain English
- Fires every even hour, Monday through Friday
- 60 runs per week
Why it’s written this way
*/2 in the hour field yields 0, 2, 4 … 22 — every even hour — while day-of-week 1-5 restricts those runs to Monday through Friday. Day-of-month is untouched, so only the weekday field is doing any filtering.
Because day-of-month stays *, there's no OR-versus-AND ambiguity here: with only ONE of the two day fields restricted, cron behaves like a plain filter — weekends are simply excluded, nothing more surprising than that.
Edge cases to know
- →Even hours means the job never fires at odd hours like 09:00 or 13:00 — if 'business hours' really means 9-to-5, this lands at 10, 12, 14, 16, not on those neat boundaries. Use an explicit hour list if exact times matter.
- →The last weekday run is 22:00 Friday; nothing fires again until 00:00 Monday — a roughly 50-hour gap that can look like an outage on a dashboard expecting continuous data.
- →A public holiday that falls on a weekday still runs the job — day-of-week only knows Monday-through-Friday as calendar positions, not which of them are actually working days.
Part by part
- 0 */2
- Minute zero of every second hour, counting from zero — so the even hours, midnight through 22:00. Twelve runs on each qualifying day.
- * * 1-5
- Calendar fields open, day-of-week restricted to Monday through Friday. The range works here because the working week is contiguous in cron's numbering.
Common mistakes
0 */2 * * 1-5 expecting it to stop overnightThe hour step covers all twenty-four hours, so this fires at 02:00 and 04:00 on weekdays too. Restricting the day does nothing about the time of day — the hour field needs a range as well.
0 9-17/2 * * 1-50 */2 * * 1-5 on a machine set to UTCWeekday boundaries are computed in the daemon's timezone, so for a team several hours away the schedule starts and ends on the wrong day. The Monday run can land on Sunday evening locally.
0 */2 * * 1-5,6Adding 6 to the range includes Saturday, which contradicts the intent the rest of the line states. It is an easy edit to make while debugging and an easy one to forget to remove.
Questions
How do I confine it to office hours as well?
Put a range in the hour field with the step: 9-17/2 fires at 09:00, 11:00, 13:00, 15:00 and 17:00. Steps apply within a range, which is the part people miss when combining the two.
Does the step restart each day?
Yes — the hour field is evaluated per day, so every qualifying day gets the same set of hours. Steps never carry state across field boundaries.
What decides which day counts as a weekday?
The daemon's timezone at the moment of evaluation. On a server in UTC serving a team in Asia or the Americas, that boundary is several hours away from the local working day — set CRON_TZ if it matters.
How many runs is this per week?
Sixty: twelve a day across five days. Worth computing before enabling anything that costs money per invocation, since the multiplication is easy to overlook.