Cron Expression: Minutes 0, 20, 40 Every Hour (0,20,40 * * * *)
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: Minutes 0, 20, 40 Every Hour (0,20,40 * * * *)
The cron expression 0,20,40 * * * * executes a task at minutes 0, 20, and 40 of every hour, making it ideal for regular hourly operations that need to run three times per hour at specific intervals.
Expression Breakdown
0,20,40 * * * *
│ │ │ │ │
│ │ │ │ └─── Day of week: * (every day)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └───────── Hour: * (every hour)
└───────────────── Minute: 0,20,40 (minutes 0, 20, and 40)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | 0,20,40 | At minutes 0, 20, and 40 |
| Hour | * | Every hour (0-23) |
| Day of Month | * | Every day (1-31) |
| Month | * | Every month (1-12) |
| Day of Week | * | Every day of week (0-7) |
List Syntax
The 0,20,40 in the minute field is a list that means "at minutes 0, 20, and 40":
- Runs at: :00, :20, :40 of every hour
- Total: 3 executions per hour × 24 hours = 72 executions per day
Execution Time
This expression runs 72 times per day at:
- Every hour at :00, :20, and :40 (e.g., 00:00, 00:20, 00:40, 01:00, 01:20, 01:40, etc.)
Common Use Cases
1. Regular Monitoring
0,20,40 * * * * /usr/local/bin/regular-monitor.sh
Monitor system health or services three times per hour.
2. Queue Processing
0,20,40 * * * * /usr/bin/node /app/process-queue.js
Process job queues or message queues three times per hour.
3. Data Synchronization
0,20,40 * * * * /usr/bin/python3 /scripts/sync-data.py
Sync data from external systems or APIs three times per hour.
4. Cache Refresh
0,20,40 * * * * /usr/bin/python3 /scripts/refresh-cache.py
Refresh cached data or computed values three times per hour.
Example Implementations
Regular Monitor Script
#!/bin/bash
# /usr/local/bin/regular-monitor.sh
LOG_FILE="/var/log/regular-monitor.log"
THRESHOLD_CPU=80
THRESHOLD_MEM=85
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
- Regular Intervals: Provides consistent 20-minute intervals
- Execution Time: Tasks should complete within 15-18 minutes
- Error Handling: Implement comprehensive error handling and logging
- Idempotency: Ensure tasks can run multiple times safely
- Resource Management: Monitor CPU, memory, and I/O usage
When to Use
✅ Good for:
- Regular monitoring
- Queue processing
- Data synchronization
- Cache refresh
- Tasks needing 3x per hour execution
❌ Avoid for:
- Real-time critical operations (use every minute)
- Very long-running processes
- Tasks requiring more frequent execution
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Minutes 0,20,40 | 0,20,40 * * * * | 3 times per hour |
| Every 20 minutes | */20 * * * * | Every 20 minutes |
| Every 15 minutes | */15 * * * * | Every 15 minutes |
Conclusion
The 0,20,40 * * * * expression is perfect for tasks that need to run three times per hour at regular 20-minute intervals. It provides a good balance between frequency and resource usage, making it ideal for regular monitoring, queue processing, and data synchronization.
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!