PatternCron

Every 30 minutes, business hours only

Steps, a range and a weekday span in one expression: a half-hourly poll that goes quiet at night and on weekends.

Last updated

Pattern
*/30 9-17 * * 1-5
Open in Crontab Schedule Creator

In plain English

  • Fires at :00 and :30, 09:00–17:30, Mon–Fri
  • 18 runs per weekday

Why it’s written this way

Each field constrains independently and the job fires when ALL of them match: minute divisible by 30, hour between 9 and 17, weekday Monday–Friday. Three simple constraints compose into "half-hourly during working hours" without any single field being clever.

This shape — a step for frequency, a range for the window, a weekday span for the calendar — is the template for most "only while people are watching" schedules.

Edge cases to know

  • →The 9-17 range is inclusive, so the LAST run is 17:30, not 17:00 — an off-by-half-hour that surprises people; use 9-16 to stop at 16:30.
  • →The day-of-month/day-of-week OR rule doesn't bite here because day-of-month is starred — it only ambushes expressions that restrict both.

Part by part

*/30
A step in the minute field: minute 0 and minute 30 of each qualifying hour. It is shorthand for the list 0,30 rather than a rolling half-hour timer.
9-17
A range in the hour field, nine through seventeen inclusive. Seventeen means the 17:00 and 17:30 runs both happen, which is one detail worth checking against what you meant.
* *
Day-of-month and month unrestricted, so the schedule repeats every week rather than being tied to a date.
1-5
Monday through Friday. Sunday is 0 in cron, so the working week is 1-5 and not 0-4.

Common mistakes

  • */30 9-17 * * 1-5 expecting it to stop at 17:00

    A range in cron is inclusive at both ends, so hour 17 is a qualifying hour and both 17:00 and 17:30 fire. If the last run should be 17:00, the minute field needs narrowing rather than the hour range.

    */30 9-16 * * 1-5
  • */30 9-17 * * 0-4

    The classic weekday off-by-one. Because Sunday is 0, this covers Sunday to Thursday — it looks like five working days and silently includes the weekend while missing Friday.

  • 0,30 9-17 * * 1-5 written as 0-30

    A hyphen where a comma was meant turns two runs an hour into thirty-one consecutive minute-by-minute runs at the top of each hour. Comma is a list, hyphen is a range, and they are one keystroke apart.

Questions

Does it respect public holidays?

No. Cron has no holiday calendar, so this fires on every weekday including national holidays. If that matters the check belongs in the script, usually against a list you maintain or a calendar service.

Whose business hours are these?

The server's. Cron uses the daemon's timezone, which is often UTC on a hosted machine, so a schedule that reads as nine-to-five can run overnight for the team it was written for. Set CRON_TZ or confirm the daemon before trusting it.

How many times a day does this actually run?

Eighteen: two runs an hour across nine qualifying hours, nine through seventeen inclusive. Multiplied across five weekdays that is ninety runs a week, which is worth knowing if each one costs money.

Can I exclude a lunch break?

Not in a single field, because the hour range is contiguous. Either use a list such as 9-12,14-17 to skip the hour, or let the script exit early during the window you want quiet.

Related in Patterns