Cron Expression: Weekdays 9 AM to 6 PM (0 9-18 * * 1-5)
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: Weekdays 9 AM to 6 PM (0 9-18 * * 1-5)
The cron expression 0 9-18 * * 1-5 executes a task every hour on weekdays (Monday through Friday) between 9 AM and 6 PM, making it ideal for business-hour operations, reports, and tasks that should run only during workdays.
Expression Breakdown
0 9-18 * * 1-5
│ │ │ │ │
│ │ │ │ └─── Day of week: 1-5 (Monday to Friday)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └─────────── Hour: 9-18 (9 AM to 6 PM)
└───────────── Minute: 0 (at minute 0)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 (top of hour) |
| Hour | 9-18 | Hours 9 through 18 (9 AM to 6 PM) |
| Day of Month | * | Every day (1-31) |
| Month | * | Every month (1-12) |
| Day of Week | 1-5 | Monday through Friday |
Combined Syntax
- Range (
9-18): Hours 9 through 18 - Range (
1-5): Monday through Friday - Combined: Every hour from 9 AM to 6 PM on weekdays only
Execution Time
This expression runs 50 times per week (10 hours × 5 weekdays) at:
- Monday-Friday: 09:00, 10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00, 17:00, 18:00
Common Use Cases
1. Business Hour Reports
0 9-18 * * 1-5 /usr/bin/python3 /scripts/generate-hourly-report.py
Generate hourly reports during business hours on weekdays.
2. Business Hour Monitoring
0 9-18 * * 1-5 /usr/local/bin/business-hour-monitor.sh
Monitor system health or services hourly during workdays.
3. Business Hour Data Sync
0 9-18 * * 1-5 /usr/bin/python3 /scripts/sync-hourly-data.py
Sync data from external systems or APIs hourly during business hours.
4. Business Hour Cache Refresh
0 9-18 * * 1-5 /usr/bin/python3 /scripts/refresh-cache.py
Refresh cached data or computed values hourly during workdays.
Example Implementations
Business Hour 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'),
'day_type': 'business_day',
'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/business_hour_{end_time.strftime("%Y%m%d_%H")}.json', 'w') as f:
json.dump(report, f, indent=2)
print(f"{datetime.now()}: Business hour report generated")
conn.close()
if __name__ == '__main__':
generate_hourly_report()
Best Practices
- Business Hours Only: Excludes weekends and off-hours
- 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:
- Business hour reports
- Business hour monitoring
- Business hour data sync
- Tasks that should only run during workdays
- Regular business-hour operations
❌ Avoid for:
- Tasks that need to run every day including weekends
- Real-time critical operations (use every minute)
- Very long-running processes
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Weekdays 9-6 | 0 9-18 * * 1-5 | Business hours, weekdays only |
| Every day 9-5 | 0 9-17 * * * | Business hours, every day |
| Weekdays at 8 AM | 0 8 * * 1-5 | Weekdays only, once daily |
Conclusion
The 0 9-18 * * 1-5 expression is perfect for business-hour operations on weekdays only. It's commonly used for hourly reports, monitoring, and data synchronization during work hours, excluding weekends and off-hours from the schedule.
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!