Cron Expression: Every Minute Between 9 AM and 5 PM (* 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 Minute Between 9 AM and 5 PM (* 9-17 * * *)
The cron expression * 9-17 * * * executes a task every minute during business hours (9 AM to 5 PM), making it ideal for real-time monitoring, health checks, and tasks that need frequent execution during work hours.
Expression Breakdown
* 9-17 * * *
│ │ │ │ │
│ │ │ │ └─── Day of week: * (every day)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └─────────── Hour: 9-17 (9 AM to 5 PM)
└───────────── Minute: * (every minute)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | * | Every minute (0-59) |
| 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 every minute from 09:00 to 17:59
- Total: 9 hours × 60 minutes = 540 executions per day
Execution Time
This expression runs 540 times per day during:
- Every minute from 9:00 AM to 5:59 PM
Common Use Cases
1. Real-Time Monitoring
* 9-17 * * * /usr/local/bin/real-time-monitor.sh
Monitor system health, application status, or service availability during business hours.
2. Queue Processing
* 9-17 * * * /usr/bin/node /app/process-queue.js
Process job queues or message queues continuously during business hours.
3. Health Checks
* 9-17 * * * /usr/local/bin/health-check.sh
Perform frequent health checks on critical services during work hours.
4. Data Collection
* 9-17 * * * /usr/bin/python3 /scripts/collect-metrics.py
Collect real-time metrics, logs, or sensor data during business hours.
Example Implementations
Real-Time Monitor Script
#!/bin/bash
# /usr/local/bin/real-time-monitor.sh
LOG_FILE="/var/log/realtime-monitor.log"
THRESHOLD_CPU=85
THRESHOLD_MEM=90
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1)
MEM_USAGE=$(free | grep Mem | awk '{printf "%.0f", $3/$2 * 100}')
if (( $(echo "$CPU_USAGE > $THRESHOLD_CPU" | bc -l) )); then
echo "$(date): WARNING - CPU usage at ${CPU_USAGE}%" >> $LOG_FILE
fi
if [ $MEM_USAGE -gt $THRESHOLD_MEM ]; then
echo "$(date): WARNING - Memory usage at ${MEM_USAGE}%" >> $LOG_FILE
fi
Best Practices
- Resource Usage: Every-minute execution is resource-intensive; keep tasks lightweight
- Execution Time: Tasks must complete within 30-40 seconds to avoid overlap
- Error Handling: Implement comprehensive error handling and logging
- Idempotency: Ensure tasks can run multiple times safely
- Monitoring: Track execution time and failures closely
When to Use
✅ Good for:
- Real-time monitoring during business hours
- Frequent health checks
- Queue processing
- Data collection
- Critical service monitoring
❌ Avoid for:
- Heavy computations
- Long-running processes
- Tasks requiring more than 30 seconds
- Operations outside business hours
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Every minute 9-5 | * 9-17 * * * | Business hours, every minute |
| Every hour 9-5 | 0 9-17 * * * | Business hours, every hour |
| Every 5 min 9-5 | */5 9-17 * * * | Business hours, every 5 minutes |
Conclusion
The * 9-17 * * * expression is perfect for real-time monitoring and frequent checks during business hours. It provides maximum responsiveness during work hours while avoiding unnecessary execution outside business time, making it ideal for critical monitoring and queue processing during peak usage periods.
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!