Cron Syntax Explained: 25 Real Schedules and Common Mistakes

A traditional five-field cron expression is read as minute, hour, day of month, month, day of week. That simple order is easy to remember; the mistakes usually come from ranges, steps, dialect differences and time zones.

# min hour day month weekday
  *   *    *   *     *

Twenty-five five-field cron examples

ExpressionTypical meaning
0 9 * * *09:00 every day
30 9 * * *09:30 every day
0 */6 * * *Every 6 hours at minute 0
*/15 * * * *Every 15 minutes
0 0 * * 0Midnight on Sunday
0 8 * * 1-508:00 Monday–Friday
0 18 * * 1-518:00 Monday–Friday
0 9 * * 109:00 every Monday
0 9 1 * *09:00 on day 1 of each month
0 9 1 1 *09:00 on January 1
5 0 * * *00:05 every day
0 2 * * *02:00 every day
0 2 * * 602:00 every Saturday
0 12 15 * *12:00 on day 15
0 0 1 */3 *Midnight on day 1 every third month in implementations supporting that step
10,40 * * * *Minute 10 and 40 of every hour
0 9,13,17 * * *09:00, 13:00 and 17:00 daily
0 9-17 * * *Every hour from 09:00 through 17:00
*/5 9-17 * * 1-5Every 5 minutes during weekday working hours
45 23 * * *23:45 daily
0 4 1,15 * *04:00 on day 1 and 15
0 7 * 6-8 *07:00 during June–August
0 0 * * 1,3,5Midnight Monday, Wednesday, Friday
20 3 * * 003:20 Sunday
0 0 31 * *Midnight on the 31st only in months that have a 31st

The day-of-month/day-of-week trap

Traditional cron implementations can treat day-of-month and day-of-week in a way that surprises developers when both are restricted. Do not assume the expression means a simple logical AND across every field. Check the manual for the scheduler you actually use, especially if you are translating an expression into Quartz, Kubernetes, a cloud scheduler or a JavaScript library.

Environment is part of the schedule

The same five fields can run at different wall-clock times if one server uses UTC and another uses a local timezone. Cron also runs with a different environment from your interactive shell: PATH, working directory, credentials and loaded shell profile can differ. Use absolute paths and explicit environment configuration for production jobs.

Failure-proof scheduled jobs

  • Make jobs idempotent where possible so a retry does not duplicate side effects.
  • Use locking for work that must not overlap.
  • Capture stdout/stderr or structured logs so failures are visible.
  • Set timeouts for network work.
  • Record the last successful run and alert on missed schedules when the task matters.
  • Document the scheduler timezone beside the expression.

The Cron Expression Humanizer is helpful for a first interpretation, and the Cron Next Run Calculator is useful for spot checks. Your scheduler’s own documentation remains the final authority.

Reference

crontab(5) — Linux man-pages

About the review

This guide is maintained by William. Technical claims are checked against primary or authoritative references where applicable. See How We Test CodeNimbleTools for the site-wide review and correction process.