Backend Developer
Cron for backend developers: the 5 expressions you'll use in production
Memorize the 5 core cron expressions. Always set the timezone explicitly and guard against overlapping runs with a lock file. These two gotchas cause most production cron incidents.
Backend developers schedule recurring jobs with cron, and 5 expressions cover 90% of production use cases: every 5 minutes (*/5 * * * *), hourly (0 * * * *), daily at midnight (0 0 * * *), weekly on Sunday (0 0 * * 0), and monthly on the 1st (0 0 1 * *).
Why this matters for you
The two gotchas that bite in production: timezones and overlapping runs. Cron uses the server's timezone, so a job scheduled at 2 AM runs at 2 AM UTC on a cloud server, not your local time. Always set TZ in the crontab or use a UTC-aware scheduler. Overlapping runs happen when a job takes longer than its interval. A 5-minute job on a */5 schedule will pile up if it takes 6 minutes. Use flock or a lock file to prevent concurrent execution.
Verdict
Memorize the 5 core cron expressions. Always set the timezone explicitly and guard against overlapping runs with a lock file. These two gotchas cause most production cron incidents.
