Cron Job Examples
Practical scheduling patterns for common tasks
8 min readDeveloper Guide
Generate Cron Expressions
Visual cron generator with syntax help
Cron Syntax Quick Reference
Cron expression format: minute hour day month weekday
Minute
0-59
Hour
0-23
Day
1-31
Month
1-12
Weekday
0-7
Special characters: * (any), /n (every n), , (list), - (range). Weekday: 0 and 7 both mean Sunday.
Common Cron Patterns
| Schedule | Expression | Description | Use Case |
|---|---|---|---|
| Every Minute | * * * * * | Runs every minute. Use sparingly - can create high load. | Real-time monitoring, health checks |
| Every 5 Minutes | */5 * * * * | Runs at minutes 0, 5, 10, 15, 20, etc. | API polling, cache refresh, queue processing |
| Every 15 Minutes | */15 * * * * | Runs at minutes 0, 15, 30, 45. | Log rotation, status checks, notification queues |
| Every Hour | 0 * * * * | Runs at the start of every hour (00:00, 01:00, etc.) | Hourly reports, data aggregation, cleanup tasks |
| Every Hour at Minute 30 | 30 * * * * | Runs at 00:30, 01:30, 02:30, etc. | Staggered tasks to avoid peak load |
| Every 2 Hours | 0 */2 * * * | Runs at 00:00, 02:00, 04:00, etc. | Batch processing, backup verification |
| Every 6 Hours | 0 */6 * * * | Runs at 00:00, 06:00, 12:00, 18:00. | Daily backups (4x), index rebuilding |
| Daily at Midnight | 0 0 * * * | Runs once per day at 00:00. | Daily backups, report generation, cleanup |
| Daily at 2 AM | 0 2 * * * | Runs at 02:00 every day. | Off-peak backups, database maintenance |
| Daily at 6:30 AM | 30 6 * * * | Runs at 06:30 every day. | Morning reports, email notifications |
| Twice Daily (9 AM and 5 PM) | 0 9,17 * * * | Runs at 09:00 and 17:00. | Start/end of day reports, sync tasks |
| Every Sunday at Midnight | 0 0 * * 0 | Runs at 00:00 every Sunday. | Weekly reports, full backups, cleanup |
| Every Monday at 9 AM | 0 9 * * 1 | Runs at 09:00 every Monday. | Weekly planning reports, team notifications |
| Weekdays at 8 AM | 0 8 * * 1-5 | Runs Monday through Friday at 08:00. | Workday automation, status reports |
| First Day of Month | 0 0 1 * * | Runs on the 1st of every month at midnight. | Monthly reports, billing, archiving |
| Quarterly (1st of Jan, Apr, Jul, Oct) | 0 0 1 1,4,7,10 * | Runs on first day of quarter months. | Quarterly reviews, major backups |
| Yearly (Jan 1) | 0 0 1 1 * | Runs once per year on January 1. | Annual cleanup, year-end processing |
Real-World Scenarios
Database Backup Strategy
0 2 * * *Full backup daily at 2 AM (off-peak)0 */6 * * *Incremental backup every 6 hours0 0 * * 0Weekly full backup with cleanupServer Health Monitoring
*/5 * * * *Check disk space, memory, CPU every 5 min*/15 * * * *Check SSL certificate expiry0 8 * * 1-5Daily morning health report emailLog & Cache Cleanup
0 0 * * *Delete logs older than 30 days daily0 3 * * 0Clear cache weekly at 3 AM Sunday0 0 1 * *Archive monthly logs, free disk spaceCron Best Practices
Avoid running jobs at :00 - spread load across different minutes
Use full paths for commands - cron has limited environment
Log output to files - silent failures are hard to debug
Add lock files to prevent overlapping runs
Set timezone explicitly if server differs from your location
Test cron expressions before deploying
Backend Tools
Related Guides
Z
Written by Zhisan
Independent Developer · Last updated June 2026