Cron Expression Patterns
This guide covers common cron expression patterns, tips for choosing the right schedule, and pitfalls to avoid.
Common patterns
High-frequency monitoring
| Expression | Schedule | Use case |
|---|---|---|
* * * * * | Every minute | Critical health checks, uptime monitoring |
*/2 * * * * | Every 2 minutes | Near-real-time status polling |
*/5 * * * * | Every 5 minutes | Standard health checks |
*/15 * * * * | Every 15 minutes | Periodic data freshness checks |
*/30 * * * * | Every 30 minutes | Semi-frequent syncs |
Standard schedules
| Expression | Schedule | Use case |
|---|---|---|
0 * * * * | Every hour (at :00) | Hourly aggregation, cache refresh |
0 */2 * * * | Every 2 hours | Periodic batch processing |
0 */6 * * * | Every 6 hours | Quarterly reports, data syncs |
0 */12 * * * | Every 12 hours | Twice-daily maintenance |
Daily schedules
| Expression | Schedule | Use case |
|---|---|---|
0 0 * * * | Daily at midnight | Nightly cleanup, log rotation |
0 2 * * * | Daily at 2 AM | Off-peak data processing |
0 9 * * * | Daily at 9 AM | Morning reports, notifications |
30 8 * * 1-5 | Weekdays at 8:30 AM | Business-hours only tasks |
Weekly and monthly
| Expression | Schedule | Use case |
|---|---|---|
0 0 * * 1 | Every Monday at midnight | Weekly reports |
0 9 * * 5 | Every Friday at 9 AM | End-of-week summaries |
0 0 1 * * | First of the month at midnight | Monthly billing, reports |
0 0 15 * * | 15th of the month at midnight | Mid-month checks |
Staggering schedules
If you have multiple crons that run at the same interval, stagger their start times to avoid thundering-herd effects on your endpoints:
# Instead of all at :000 * * * * # Cron A — every hour at :005 * * * * # Cron B — every hour at :0510 * * * * # Cron C — every hour at :10For daily crons, spread them across the early morning hours instead of all at midnight:
0 0 * * * # Job A — midnight0 1 * * * # Job B — 1 AM0 2 * * * # Job C — 2 AMTimezone considerations
Cron expressions are evaluated in UTC. If your business logic depends on local time zones, convert your desired local time to UTC:
| Local time (US Eastern, UTC-5) | UTC equivalent | Cron expression |
|---|---|---|
| 9 AM ET | 2 PM UTC | 0 14 * * * |
| Midnight ET | 5 AM UTC | 0 5 * * * |
| 5 PM ET | 10 PM UTC | 0 22 * * * |
Pitfalls to avoid
Running too frequently
Every-minute crons (* * * * *) consume your monthly request quota quickly. A cron firing every minute uses 43,200 requests per month. Use 5-minute intervals (*/5 * * * *) unless you genuinely need per-minute resolution.
Long-running endpoints with short intervals
If your endpoint takes 90 seconds to respond but the cron fires every minute, you will have overlapping executions. Each execution is independent — Recuro does not wait for the previous one to finish. Set your interval longer than your expected response time, or set a shorter timeout_seconds and fix the slow endpoint.
Forgetting about DST
Because cron expressions use UTC, daylight saving time shifts will affect the local-time equivalent of your schedule. A cron at 0 14 * * * (UTC) is 9 AM Eastern Standard Time but 10 AM Eastern Daylight Time. If exact local time matters, adjust your cron expression seasonally or schedule at a time that is acceptable in both offsets.
Next steps
- Cron Schedules — Full concept reference
- Creating a Cron Schedule — Step-by-step guide
- Retry Strategy Design — For queue-based jobs