Cron & Scheduled Tasks Patterns
Scheduled task patterns covering cron syntax, job scheduling, distributed locking, monitoring, and production best practices.
- Difficulty
- intermediate
- Read time
- 1 min read
- Version
- v1.0.0
- Confidence
- established
- Last updated
Quick Reference
Cron Jobs: Use distributed locks to prevent concurrent execution. Log start/end times. Set timeouts shorter than interval. Monitor execution and alert on failures. Use node-cron for simple, BullMQ for complex scheduling. Avoid minute 0 (load spike). Make jobs idempotent. Store execution history.
Use When
- Periodic data sync
- Report generation
- Cleanup tasks
- Health checks
- Billing cycles
Skip When
- One-time tasks
- Event-driven processing
- Real-time requirements
Cron & Scheduled Tasks Patterns
Scheduled task patterns covering cron syntax, job scheduling, distributed locking, monitoring, and production best practices.