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
- • Refreshing dashboards during work hours only
- • Sending notifications only during business hours
- • Running resource-intensive queries when staff is available
- • Polling for updates during the workday
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
- ✓ 9-17 runs at hours 9, 10, 11, 12, 13, 14, 15, 16, 17 (9 runs per day)
- ✓ Combine with 1-5 for Monday through Friday
- ✓ Saves resources by not running during nights and weekends
- ✓ Adjust hours and days for your specific business schedule
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.