Cron Expression: Every Hour Between 9 AM and 5 PM (0 9-17 * * *)
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!
Cron Expression: Every Hour Between 9 AM and 5 PM (0 9-17 * * *)
The cron expression 0 9-17 * * * executes a task every hour during business hours (9 AM to 5 PM), making it ideal for regular monitoring, reports, and tasks that should run hourly during work hours.
Expression Breakdown
0 9-17 * * *
│ │ │ │ │
│ │ │ │ └─── Day of week: * (every day)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └─────────── Hour: 9-17 (9 AM to 5 PM)
└───────────── Minute: 0 (at minute 0)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 (top of hour) |
| Hour | 9-17 | Hours 9 through 17 (9 AM to 5 PM) |
| Day of Month | * | Every day (1-31) |
| Month | * | Every month (1-12) |
| Day of Week | * | Every day of week (0-7) |
Range Syntax
The 9-17 in the hour field is a range that means "hours 9 through 17":
- Runs at: 09:00, 10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00, 17:00
- Total: 9 executions per day
Execution Time
This expression runs 9 times per day at:
- 09:00, 10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00, 17:00
Common Use Cases
1. Hourly Business Reports
0 9-17 * * * /usr/bin/python3 /scripts/generate-hourly-report.py
Generate hourly reports during business hours.
2. Hourly Health Checks
0 9-17 * * * /usr/local/bin/hourly-health-check.sh
Perform hourly health checks on services during work hours.
3. Hourly Data Sync
0 9-17 * * * /usr/bin/python3 /scripts/sync-hourly-data.py
Sync data from external systems or APIs hourly during business hours.
4. Hourly Cache Refresh
0 9-17 * * * /usr/bin/python3 /scripts/refresh-hourly-cache.py
Refresh cached data or computed values hourly during work hours.
Example Implementations
Hourly Business Report Script
# generate-hourly-report.py
import json
from datetime import datetime, timedelta
import sqlite3
def generate_hourly_report():
conn = sqlite3.connect('/var/data/app.db')
cursor = conn.cursor()
# Get data from last hour
end_time = datetime.now()
start_time = end_time - timedelta(hours=1)
cursor.execute('''
SELECT
COUNT(*) as total_requests,
AVG(response_time) as avg_response_time,
COUNT(CASE WHEN status_code >= 400 THEN 1 END) as errors
FROM requests
WHERE timestamp >= ? AND timestamp < ?
''', (start_time, end_time))
metrics = cursor.fetchone()
report = {
'hour': end_time.strftime('%Y-%m-%d %H:00'),
'metrics': {
'total_requests': metrics[0],
'avg_response_time': round(metrics[1], 2) if metrics[1] else 0,
'errors': metrics[2]
}
}
with open(f'/var/reports/hourly_{end_time.strftime("%Y%m%d_%H")}.json', 'w') as f:
json.dump(report, f, indent=2)
print(f"{datetime.now()}: Hourly business report generated")
conn.close()
if __name__ == '__main__':
generate_hourly_report()
Best Practices
- Business Hours: Aligns with typical 9-to-5 work schedule
- Error Handling: Implement comprehensive error handling and logging
- Locking: Use file locks to prevent concurrent execution
- Monitoring: Set up alerts for failed jobs
- Performance: Optimize tasks to complete quickly during business hours
When to Use
✅ Good for:
- Hourly reports during business hours
- Hourly health checks
- Hourly data sync
- Hourly cache refresh
- Regular business-hour operations
❌ Avoid for:
- Real-time critical operations (use every minute)
- Very long-running processes
- Tasks outside business hours
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Every hour 9-5 | 0 9-17 * * * | Business hours, every hour |
| Every 5 min 9-5 | */5 9-17 * * * | Business hours, every 5 minutes |
| Every minute 9-5 | * 9-17 * * * | Business hours, every minute |
Conclusion
The 0 9-17 * * * expression is perfect for hourly operations during business hours. It's commonly used for hourly reports, health checks, and data synchronization, providing regular updates during work hours while avoiding execution outside business time.
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!