Cron expression for every hour during business hours
0 9-17 * * 1-5
Every hour, between 09:00 and 17:00, Monday through Friday. It runs 9 times on each matching day, on 261 days a year (2,349 runs).
Runs on the hour from 09:00 to 17:00 on weekdays: nine runs a day, 45 a week. Check the server’s time zone first. On a UTC server this matches London office hours in winter, but means 4 AM to noon in New York.
Field by field
| Field | Value | Matches |
|---|---|---|
| minute | 0 |
0 |
| hour | 9-17 |
9–17 |
| day of month | * |
every value |
| month | * |
every value |
| day of week | 1-5 |
MON–FRI |
Examples
crontab
Run crontab -e and add:
0 9-17 * * 1-5 /usr/local/bin/job.sh >> /var/log/job.log 2>&1
Kubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "0 9-17 * * 1-5"
timeZone: "Etc/UTC" # Kubernetes 1.27+
concurrencyPolicy: Forbid # skip a run if the last one is still going
jobTemplate:
spec:
template:
spec:
containers:
- name: job
image: ghcr.io/acme/job:1.0
restartPolicy: OnFailure
GitHub Actions
on:
schedule:
- cron: '0 9-17 * * 1-5' # UTC
GitHub evaluates schedules in UTC, and runs can start several minutes late at busy times.
systemd timer
# /etc/systemd/system/job.timer
[Unit]
Description=Run job.service every hour during business hours
[Timer]
OnCalendar=Mon..Fri *-*-* 09..17:00:00
Persistent=true
[Install]
WantedBy=timers.target
Enable it with systemctl enable --now job.timer, and check the next runs with
systemd-analyze calendar "Mon..Fri *-*-* 09..17:00:00". Persistent=true runs a missed job after
downtime, which cron can’t do.
AWS EventBridge
cron(0 9-17 ? * MON-FRI *)
EventBridge cron has six fields (the last is the year), uses ? in either the day-of-month or the
day-of-week field, and numbers weekdays from 1 (Sunday) to 7. Rules run in UTC; EventBridge Scheduler also
accepts a time zone.
Similar schedules: hourly
-
Every hour:
0 * * * * -
Every hour at half past:
30 * * * * -
Every 2 hours:
0 */2 * * * -
Every 3 hours:
0 */3 * * * -
Every 4 hours:
0 */4 * * * -
Every 6 hours:
0 */6 * * * -
Every 8 hours:
0 */8 * * * -
Every 12 hours:
0 */12 * * *
Have a different schedule? Paste any expression into the Cron Expression Generator, or browse all cron examples.
Sources
- POSIX: crontab
- crontab(5) manual page
- Kubernetes docs: CronJob
- GitHub Actions docs: schedule event
- systemd.time(7): calendar events
- AWS docs: EventBridge Scheduler cron expressions
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
How do I run a cron job every hour during business hours?
Use 0 9-17 * * 1-5. It means “Every hour, between 09:00 and 17:00, Monday through Friday”. It runs 9 times on each matching day, on 261 days a year (2,349 runs).