Cron is the scheduler that runs most of the internet. Every database backup, every log rotation, every daily email digest, every weekly report — all running on cron. Yet most developers only know the basics. Let us fix that.
The 5 fields
A standard cron expression has 5 space-separated fields:
* * * * * command || | | | | || | | | +----- day of week (0-6, Sunday=0) || | | +------- month (1-12) || | +--------- day of month (1-31) || +----------- hour (0-23) |+------------- minute (0-59)
There is also an extended 6-field syntax used by some schedulers (Quartz, Spring) that adds seconds at the front.
Special characters
Cron has only four special characters, but they compose into infinite patterns:
*— any value.* * * * *runs every minute.,— list.0 9,12,18 * * *runs at 9am, 12pm, and 6pm.-— range.0 9-17 * * *runs every hour from 9am to 5pm./— step.*/15 * * * *runs every 15 minutes.
You can combine them: 0 9-17/2 * * 1-5 means weekdays from 9am to 5pm, every 2 hours.
Predefined aliases
Most cron implementations support these shortcuts:
@yearly/@annually—0 0 1 1 *@monthly—0 0 1 * *@weekly—0 0 * * 0@daily/@midnight—0 0 * * *@hourly—0 * * * *@reboot— once at startup
Common patterns
- Every 5 minutes:
*/5 * * * * - Every 15 minutes:
*/15 * * * * - Every weekday at 9am:
0 9 * * 1-5 - First day of every month at midnight:
0 0 1 * * - Every Sunday at 3am:
0 3 * * 0 - Twice a day (9am and 9pm):
0 9,21 * * * - Every 30 seconds (Quartz only):
*/30 * * * * *
Gotchas
Day-of-month AND day-of-week: When both fields are restricted (not *), cron uses OR, not AND. 0 0 1 * 1 runs on the 1st of the month AND on every Monday — not on the 1st when it is a Monday.
Timezone: Cron runs in the system timezone. 0 9 * * * means 9am in the server's timezone, not yours. Always check with TZ=UTC date.
DST: Cron jobs can be skipped or run twice during daylight saving transitions. Use TZ=Etc/UTC or your distribution's cronie with timezone support.
Overlapping runs: If a job takes longer than the cron interval, multiple instances can run simultaneously. Use file locks (flock) or a queue.
Parse and test cron expressions with our Cron Parser.
Frequently Asked Questions
Q: What does */5 * * * * mean?
It means run every 5 minutes. The */5 is a step value: start at minute 0 and run every 5 minutes (at :00, :05, :10, and so on). See the cron expression guide on MDN for more examples.
Q: How do I handle DST changes with cron?
Cron jobs can be skipped or run twice during DST transitions. Use UTC timezone (TZ=Etc/UTC) or your distribution's cronie with timezone support to avoid issues. crontab.guru is a useful tool to visualize cron timings.
Q: What's the difference between cron and systemd timers?
systemd timers are the modern replacement for cron on Linux. They support calendar events, monotonic timers, persistent scheduling across reboots, and better logging. But cron is still simpler for straightforward scheduled tasks and works on every Unix system including macOS.