Cron syntax explained
A cron expression is a string of five space-separated fields that define a schedule for a recurring job. Each field represents a unit of time:
┌─── minute (0–59) │ ┌─── hour (0–23) │ │ ┌─── day of month (1–31) │ │ │ ┌─── month (1–12) │ │ │ │ ┌─── day of week (0–7, both 0 and 7 = Sunday) │ │ │ │ │ * * * * *
Some implementations (Quartz Scheduler, Spring, AWS EventBridge) use a 6-field format that adds a seconds field at the beginning or a year field at the end. Standard Unix/Linux cron — the most widely used — has exactly 5 fields.
Special characters
- * — every value.
* * * * *runs every minute. - , — list.
1,15,30,45in the minute field means "at minute 1, 15, 30, and 45." - - — range.
1-5in day-of-week means Monday through Friday. - / — step.
*/10means "every 10 units."0-30/5means "every 5 minutes within the first half hour."
Cron cheat sheet — patterns every developer should know
* * * * * Every minute*/5 * * * * Every 5 minutes0 * * * * Every hour (at :00)0 0 * * * Every day at midnight0 9 * * 1-5 Weekdays at 9:00 AM0 0 * * 0 Every Sunday at midnight0 0 1 * * First day of every month0 0 1 1 * New Year's Day30 2 * * * Every night at 2:30 AM0 */6 * * * Every 6 hours0 9,17 * * 1-5 Weekdays at 9 AM & 5 PM*/30 9-17 * * 1-5 Every 30m business hoursCron timezone gotchas
Cron runs in the server's local timezone. On cloud infrastructure (EC2, GCE, container orchestrators), the system timezone is almost always UTC. A job scheduled for 0 9 * * * on a UTC server fires at 9 AM UTC — which is 2 AM PST, 5 AM EST, or 4 PM JST depending on where your users are.
Always document the timezone of your cron jobs explicitly. If your infrastructure runs in UTC but your business operates on a local timezone, use TZ= prefix (supported in GNU crontab) or a scheduler that supports named timezone expressions.
Cron vs alternatives
| Platform | Best For | Timezone Support |
|---|---|---|
| Standard cron | Simple recurring jobs on a Linux server. | System TZ only. |
| systemd timers | Service-based jobs on modern Linux (better logging). | Named TZ supported. |
| AWS EventBridge | Serverless scheduled jobs in AWS (Lambda). | UTC only. |
| GitHub Actions | CI/CD automation, periodic repo reports. | UTC only. |
| Kubernetes CronJob | Containerized periodic jobs in a cluster. | Cluster TZ or per-job TZ (1.24+). |
How to test cron expressions safely
Before deploying a cron job, paste your expression into a descriptor tool (like this one) and confirm it says what you expect. A common mistake is confusing the day-of-week and day-of-month interaction: when you specify both (neither is *), most cron implementations treat them as OR, not AND.