Cron Job Examples

Practical scheduling patterns for common tasks

8 min readDeveloper Guide

Generate Cron Expressions

Visual cron generator with syntax help

Cron Generator

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

ScheduleExpressionDescriptionUse 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 Hour0 * * * *Runs at the start of every hour (00:00, 01:00, etc.)Hourly reports, data aggregation, cleanup tasks
Every Hour at Minute 3030 * * * *Runs at 00:30, 01:30, 02:30, etc.Staggered tasks to avoid peak load
Every 2 Hours0 */2 * * *Runs at 00:00, 02:00, 04:00, etc.Batch processing, backup verification
Every 6 Hours0 */6 * * *Runs at 00:00, 06:00, 12:00, 18:00.Daily backups (4x), index rebuilding
Daily at Midnight0 0 * * *Runs once per day at 00:00.Daily backups, report generation, cleanup
Daily at 2 AM0 2 * * *Runs at 02:00 every day.Off-peak backups, database maintenance
Daily at 6:30 AM30 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 Midnight0 0 * * 0Runs at 00:00 every Sunday.Weekly reports, full backups, cleanup
Every Monday at 9 AM0 9 * * 1Runs at 09:00 every Monday.Weekly planning reports, team notifications
Weekdays at 8 AM0 8 * * 1-5Runs Monday through Friday at 08:00.Workday automation, status reports
First Day of Month0 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 hours
0 0 * * 0Weekly full backup with cleanup

Server Health Monitoring

*/5 * * * *Check disk space, memory, CPU every 5 min
*/15 * * * *Check SSL certificate expiry
0 8 * * 1-5Daily morning health report email

Log & Cache Cleanup

0 0 * * *Delete logs older than 30 days daily
0 3 * * 0Clear cache weekly at 3 AM Sunday
0 0 1 * *Archive monthly logs, free disk space

Cron 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