Cron syntax: the five fields explained

Standard cron uses five fields. Quartz and some cloud schedulers add seconds or years — those are different languages. ToolDeck explains the classic five-field form.

The five fields

* * * * *
│ │ │ │ │
│ │ │ │ └── day of week (0–7, Sunday = 0 or 7)
│ │ │ └──── month (1–12)
│ │ └────── day of month (1–31)
│ └──────── hour (0–23)
└────────── minute (0–59)

Common patterns

  • */5 * * * * — every five minutes
  • 0 * * * * — every hour on the hour
  • 0 9 * * 1-5 — 09:00 on weekdays
  • 0 0 1 * * — midnight on the first of each month
  • 30 4 * * 0 — 04:30 every Sunday

Day of month and day of week

If both day-of-month and day-of-week are restricted (not *), many crons run when either matches. That surprises people. Prefer setting only one of those fields unless you know your daemon’s rule.

Time zones

Classic system cron uses the machine’s local time. GitHub Actions and many CI systems run cron in UTC. The explainer lists next runs in your browser’s zone and says so.

Questions

Does cron use seconds?
Not in the five-field Vixie/crontab form. Six-field forms (with seconds) are a different dialect.
Is @daily portable?
Macros like @daily are common on Linux but not universal. Prefer explicit fields when sharing a schedule.

Related tool: Cron expression explainer. Runs in your browser; input is not uploaded.