Understanding Cron Jobs: From Expression to Schedule

Clock and scheduler

The first time I saw "0 9 * * 1-5", I thought someone had sneezed on my keyboard. Five years later, I can read that expression in my sleep: "At 9:00 AM, Monday through Friday." Cron expressions aren't hard once you crack the code.

The Anatomy of a Cron Expression

A cron expression has five fields: minute, hour, day of month, month, day of week. Each field can contain a specific value, a wildcard (*), a range (1-5), or a step (*/5).

# ┌───────────── minute (0-59)
# │ ┌───────────── hour (0-23)
# │ │ ┌───────────── day of month (1-31)
# │ │ │ ┌───────────── month (1-12)
# │ │ │ │ ┌───────────── day of week (0-6, Sunday=0)
# │ │ │ │ │
# * * * * * command

Common Patterns

"0 * * * *" = Every hour at minute 0 (e.g., 1:00, 2:00, 3:00)

"*/15 * * * *" = Every 15 minutes

"0 9 * * 1-5" = 9:00 AM every weekday

"0 0 1 * *" = Midnight on the first of every month

"30 4 * * 0" = 4:30 AM every Sunday

Day of Week Gotcha

In some systems, 0=Sunday, in others 0=Monday. Always verify your system's interpretation. Linux typically uses 0=Sunday.

Related Tools

Cron Generator

Generate cron expressions with descriptions.