Cron expression examples, and the mistakes that make jobs run at the wrong time

A cheat sheet of common cron schedules (every 5 minutes, hourly, weekdays at 9am, monthly) plus the time zone, day-of-week and platform differences that cause bugs.

Cron syntax is five fields and a handful of symbols, and almost nobody remembers it between uses. Most people need the same dozen schedules over and over, so they’re all in the table below. After that come the parts that actually cause bugs: time zones, the day-of-month and day-of-week rule, and the platforms that quietly use a different format.

The five fields

A standard cron expression has five fields separated by spaces, always in this order:

┌──────── minute        (0–59)
│ ┌────── hour          (0–23)
│ │ ┌──── day of month  (1–31)
│ │ │ ┌── month         (1–12 or JAN–DEC)
│ │ │ │ ┌ day of week   (0–7 or SUN–SAT; 0 and 7 are both Sunday)
│ │ │ │ │
* * * * *

Each field takes a value, or one of these:

  • * means every value: every minute, every hour and so on.
  • , separates a list: 1,15 in the day field means the 1st and the 15th.
  • - is a range: 1-5 in the day-of-week field is Monday to Friday.
  • / is a step: */10 in the minute field means every 10 minutes, and 9-17/2 in the hour field means 9, 11, 13, 15 and 17.

Common cron schedules

Times are in whatever time zone the scheduler runs in, which is often UTC (more on that below).

ScheduleCron expression
Every minute* * * * *
Every 5 minutes*/5 * * * *
Every 15 minutes*/15 * * * *
Every 30 minutes*/30 * * * *
Every hour, on the hour0 * * * *
Every 2 hours0 */2 * * *
Every day at midnight0 0 * * *
Every day at 9:000 9 * * *
Twice a day, 9:00 and 21:000 9,21 * * *
Weekdays at 9:000 9 * * 1-5
Every 30 minutes, 9:00–17:30 on weekdays*/30 9-17 * * 1-5
Every Monday at 9:000 9 * * 1
Every Sunday at midnight0 0 * * 0
1st of every month at midnight0 0 1 * *
1st and 15th of the month at 6:000 6 1,15 * *
Every quarter (1 Jan, Apr, Jul, Oct)0 0 1 1,4,7,10 *
Once a year, 1 January at midnight0 0 1 1 *

Most cron versions also accept shortcuts: @hourly, @daily (same as @midnight), @weekly (Sunday at midnight), @monthly and @yearly. Linux crontab also has @reboot, which runs once when the machine starts.

“Every 5 minutes” runs on the clock, not from when you saved it

*/5 * * * * runs at :00, :05, :10 and so on. If you add the job at 10:03, the first run is at 10:05, not 10:08. Steps count from the start of the field’s range, not from the moment the job was created.

That also means steps that don’t divide evenly give uneven gaps. */7 * * * * runs at minutes 0, 7, 14 … 49 and 56, and then at 0 again, only four minutes later. The same thing happens with */5 in the hour field: 0, 5, 10, 15, 20, and then a four-hour gap to midnight. If you need a run exactly every 7 minutes or every 5 hours, cron is the wrong tool. Use a loop with a sleep, or a scheduler that supports fixed intervals.

If several of your jobs all use 0 * * * *, they all start at the same second. Offsetting them (7 * * * *, 23 * * * *) spreads the load, and is kinder to any API you’re calling.

The day-of-month and day-of-week trap

This one surprises nearly everyone. When both day fields are set to something other than *, standard cron runs the job when either matches, not both.

So 0 9 1 * 1 doesn’t mean “9:00 on the 1st, if it’s a Monday”. It means “9:00 on the 1st of every month, and 9:00 every Monday”. There’s no way to say “first Monday of the month” in standard cron. The usual workaround is to run every Monday in the first week and let the script decide:

0 9 1-7 * * [ "$(date +\%u)" = 1 ] && /path/to/job.sh

This runs on days 1 to 7 and only continues when the weekday is Monday (%u gives 1 for Monday). The % is escaped as \% because in a crontab file an unescaped % is turned into a newline.

Time zones: the most common reason a job runs “at the wrong time”

Cron uses the time zone of whatever runs it. On your laptop that’s local time. On most servers, containers and hosted schedulers it’s UTC. A job written as 0 9 * * * on a UTC server runs at 9:00 UTC, which is 5:00 in New York in summer, 10:00 in London in summer and 14:30 in India.

  • Linux crontab uses the system time zone. Check it with timedatectl or date. Some cron versions (cronie, for example) let you set CRON_TZ= at the top of the crontab.
  • GitHub Actions schedules are always UTC. The shortest interval allowed is every 5 minutes, runs can be late when GitHub is busy (the top of the hour is the busiest), and in public repositories scheduled workflows are switched off after 60 days with no activity.
  • Kubernetes CronJobs use the controller’s time zone unless you set spec.timeZone, for example America/New_York.

Daylight saving time adds one more wrinkle when the scheduler uses local time. On the night the clocks go forward, 2:30 never happens; when they go back, 1:30 happens twice. Different cron versions handle that differently: some skip the job, some run it late, some run it twice. Schedule important jobs outside the 1:00–3:00 window, or run them in UTC.

Platforms that use a different format

Not every “cron” is standard five-field cron. If an expression is rejected, check which flavour you’re in:

  • Quartz and Spring (@Scheduled) put a seconds field first, so every 5 minutes is 0 */5 * * * * in Spring. Quartz also needs a ? in one of the two day fields and allows an optional year at the end.
  • AWS EventBridge uses six fields with a year at the end, and also needs ? in one of the day fields: cron(0 9 ? * MON-FRI *).
  • Day-of-week numbering differs too. Standard cron and Spring count Sunday as 0, while Quartz and EventBridge count Sunday as 1. Using names like MON-FRI avoids the confusion wherever they’re accepted.

Things that can’t be written in standard cron

  • The last day of the month. Quartz has L, standard cron doesn’t. Run on days 28 to 31 and check whether tomorrow is the 1st (GNU date): 0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /path/to/job.sh
  • Every N days across months. 0 0 */3 * * runs on the 1st, 4th, 7th … 31st, then again on the 1st, so the gap resets each month.
  • Anything under a minute. Cron’s smallest unit is one minute. For every 30 seconds, use a systemd timer or a long-running worker.

When a crontab job doesn’t run at all

The expression is usually fine. The environment is the problem:

  1. Use full paths. Cron runs with a minimal PATH, so python or node may not be found. Write /usr/bin/python3, or set PATH= at the top of the crontab.
  2. Log the output. Add >> /tmp/job.log 2>&1 to the end of the line, so errors end up somewhere you can read them.
  3. Escape % as \%, for example in date +\%F.
  4. End the file with a newline. Some cron versions ignore the last line if it doesn’t have one.
  5. Check you edited the right crontab. crontab -e edits your user’s jobs; files in /etc/cron.d/ need an extra user field between the schedule and the command.

Check an expression before you ship it

The Cron Generator on BayaTools works both ways. Type a schedule in plain English, like “every weekday at 9am”, and you get the expression. Paste an expression and you get it explained back to you, with the next five run times in your local time or in UTC. It follows standard five-field cron, including the day-of-month/day-of-week rule above, so what it shows is what crontab will do.

Looking at the next run times is the quickest way to catch the mistakes in this guide: a job that runs on every Monday when you wanted one Monday a month, or a 9:00 job that’s actually 9:00 UTC.

Tools from this guide

Quick answers

*/5 * * * * runs every 5 minutes, at :00, :05, :10 and so on. In Spring, which adds a seconds field, it’s 0 */5 * * * *.

More guides