Cron Expression Guide: Syntax, Examples & Common Patterns

Cron expressions are the universal language for scheduling recurring tasks. Whether you're configuring a Linux crontab, a CI/CD pipeline, or a cloud function trigger, the syntax is fundamentally the same. This guide covers everything from basic syntax to edge cases that trip up experienced developers.

Cron Expression Format

A standard cron expression has 5 fields separated by spaces:

┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-7, 0&7=Sun)
│ │ │ │ │
* * * * *

Special Characters

CharacterMeaningExampleExplanation
*Every value* * * * *Every minute
,Value list0 8,12,17 * * *At 8am, noon, and 5pm
-Range0 9-17 * * *Every hour from 9am to 5pm
/Step*/15 * * * *Every 15 minutes
LLast (extended)0 0 L * *Last day of every month
WWeekday (extended)0 0 15W * *Nearest weekday to the 15th
#Nth weekday (extended)0 0 * * 5#3Third Friday of every month

Common Cron Patterns

ScheduleExpressionExplanation
Every minute* * * * *Runs 1,440 times per day
Every 5 minutes*/5 * * * *At :00, :05, :10, ... :55
Every hour0 * * * *At the top of every hour
Daily at midnight0 0 * * *Once per day at 00:00
Daily at 9am0 9 * * *Once per day at 09:00
Weekdays at 9am0 9 * * 1-5Mon-Fri at 09:00
Weekly on Sunday0 0 * * 0Midnight every Sunday
Monthly (1st)0 0 1 * *Midnight on the 1st
Quarterly0 0 1 1,4,7,10 *Jan, Apr, Jul, Oct 1st
Yearly (Jan 1)0 0 1 1 *Midnight on January 1st
Every 30 min (business hours)*/30 9-17 * * 1-5Mon-Fri, 9am-5pm, every 30 min

Gotchas and Edge Cases

Day-of-Month vs. Day-of-Week

When both day-of-month and day-of-week are specified (not *), most cron implementations use OR logic — the job runs when either condition is met. This is counterintuitive:

  • 0 0 15 * 5 runs on the 15th of every month AND every Friday — not just Fridays that fall on the 15th
  • To run only on a specific weekday of a specific date, use conditional logic in your script

Daylight Saving Time

  • When clocks spring forward (2:00 → 3:00), jobs scheduled between 2:00-2:59 may be skipped
  • When clocks fall back (2:00 → 1:00), jobs scheduled between 1:00-1:59 may run twice
  • Schedule critical jobs at times that don't overlap with DST transitions (avoid 1:00-3:00 AM)

Standard vs. Extended Cron

SystemFieldsSecondsYearL/W/#
Unix crontab5NoNoNo
Quartz (Java)6-7YesOptionalYes
Spring @Scheduled6YesNoYes
AWS EventBridge6No (min)YesPartial
GitHub Actions5NoNoNo
💡 Tip: Always test your cron expressions before deploying. Use our Cron Parser to see exactly when your expression will fire next.

Best Practices

  • Add comments in crontab — # Database backup - daily at 2am
  • Use specific times instead of * * * * * — runaway every-minute jobs can cause resource issues
  • Log output — redirect stdout and stderr to log files
  • Handle overlapping runs — use file locks (flock) to prevent concurrent execution
  • Monitor failures — check exit codes and set up alerts for critical jobs
  • Stagger schedules — don't schedule everything at midnight; spread jobs across off-peak hours

Frequently Asked Questions

The asterisk (*) means "every possible value" for that field. In the minute field, it means every minute (0-59). It's the wildcard that matches all valid values.
They're equivalent — both mean "every 5 units starting from 0." However, 3/5 would mean "every 5 minutes starting from minute 3" (3,8,13,18...).
Use 1-5 in the day-of-week field. For example, "0 9 * * 1-5" runs at 9 AM Monday through Friday.
Standard Unix cron uses the system's local timezone. Cloud schedulers allow explicit timezone specification. Be careful during DST transitions.
Standard Unix cron uses 5 fields. Extended cron (Quartz, Spring) adds a seconds field at the beginning and sometimes a year field at the end.

Test your cron expression

Open Cron Parser →