T
ToolPrime

Cron Expression for Business Hours Only

Run a cron job every hour during business hours (9 AM to 5 PM, Monday through Friday) using 0 9-17 * * 1-5.

Expression

0 9-17 * * 1-5

Every hour from 09:00 to 17:00, Monday through Friday

Use Cases

Code Examples

Crontab

# Every hour from 09:00 to 17:00, Monday through Friday
0 9-17 * * 1-5 /path/to/your/script.sh

GitHub Actions

name: Scheduled Job
on:
  schedule:
    - cron: '0 9-17 * * 1-5'
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Running Business Hours Only"

systemd Timer

[Unit]
Description=Business Hours Only timer

[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true

[Install]
WantedBy=timers.target

Tips

Frequently Asked Questions

How do I restrict cron to business hours?

Use a range in the hour field (9-17) and day-of-week field (1-5): 0 9-17 * * 1-5 runs hourly from 9 AM to 5 PM, Monday through Friday.

Does 9-17 include hour 17?

Yes, ranges in cron are inclusive. 9-17 means hours 9, 10, 11, 12, 13, 14, 15, 16, and 17.

Related Cron Expressions