Skip to content
HandyKit

Cron Expression Examples, Explained

· 5 min read

A cron expression is five fields that describe when a job should run. It is used by the cron daemon on Linux and macOS, by Kubernetes CronJobs, GitHub Actions schedules and many job schedulers. This guide gives ready-to-use expressions for the most common schedules and explains how to write your own.

To check an expression, paste it into the Cron Expression Generator. It describes the schedule in plain English and lists the next 10 run times in your time zone or any other.

The five fields

Each expression has five fields separated by spaces, always in this order:

FieldAllowed values
Minute0–59
Hour0–23
Day of month1–31
Month1–12, or JAN–DEC
Day of week0–6, or SUN–SAT (0 and 7 are both Sunday)

So 30 9 * * 1 means minute 30, hour 9, any day of the month, any month, on Mondays: 09:30 every Monday. Hours use the 24-hour clock, so 6 PM is 18.

Common cron expressions

Each description below is what the Cron Expression Generator says about the expression.

ExpressionSchedule
*/5 * * * *Every 5 minutes
*/15 * * * *Every 15 minutes
0 * * * *Every hour
0 */6 * * *On the hour, every 6 hours
0 0 * * *At 00:00
30 2 * * *At 02:30
0 9 * * 1-5At 09:00, Monday through Friday
*/15 9-17 * * 1-5Every 15 minutes, between 09:00 and 17:59, Monday through Friday
0 0 * * 1At 00:00, only on Monday
30 18 * * 5At 18:30, only on Friday
0 0 1 * *At 00:00, on day 1 of the month
0 0 1,15 * *At 00:00, on day 1 and 15 of the month
0 0 1 */3 *At 00:00, on day 1 of the month, every 3 months
0 0 1 1 *At 00:00, on day 1 of the month, only in January
45 23 28-31 * *At 23:45, between day 28 and 31 of the month

Special characters

Four characters do most of the work:

  • * means every value. * in the hour field means every hour.
  • , separates a list of values. 0,30 in the minute field means on the hour and at half past.
  • - gives a range. 1-5 in the day-of-week field means Monday to Friday.
  • / gives a step. */15 in the minute field means every 15 minutes, and 9-17/2 in the hour field means every two hours from 09:00 to 17:00.

Steps are counted from the start of the range, not from when cron started. */5 in the minute field runs at :00, :05, :10 and so on, aligned to the clock. Likewise, */3 in the month field means January, April, July and October, because the count starts at month 1.

Running every 5 minutes

*/5 * * * * is the most searched cron expression, and the usual answer. If you want a job every 5 minutes but not at the same moment as other jobs, offset it with a list instead of a step: 2,7,12,17,22,27,32,37,42,47,52,57 * * * * runs every 5 minutes starting at :02.

Some platforms set a minimum interval. GitHub Actions, for example, runs scheduled workflows at most once every 5 minutes, and may run them later than scheduled when it is busy.

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

When both day fields are restricted, standard cron runs the job when either one matches, not when both do. This catches out almost everyone the first time.

0 0 13 * 5 looks like "midnight on Friday the 13th", but the generator describes it as: At 00:00, on day 13 of the month, and on Friday. It runs on the 13th of every month and on every Friday.

To run only on a weekday that falls on a particular date, schedule the job on the weekday and have the script check the date itself, for example with [ "$(date +%d)" = 13 ] in a shell script.

Time zones

Cron runs in the time zone of the machine it is on, and servers are often set to UTC. A job written as 0 9 * * * by someone in Colombo runs at 09:00 server time, which may be 14:30 their time. The generator shows the next runs in UTC and in any zone you choose, so you can check before deploying.

Some schedulers let you set the zone per job: Kubernetes CronJobs have a timeZone field, and cronie supports a CRON_TZ line in the crontab. GitHub Actions schedules always use UTC.

Daylight-saving changes skip or repeat an hour once a year in many zones, and cron implementations handle those hours differently. If a job must run exactly once a day, avoid scheduling it between 01:00 and 03:00 local time, or run the server in UTC.

Shortcuts

Most cron implementations accept these shortcuts in place of the five fields:

  • @hourly is 0 * * * *
  • @daily (or @midnight) is 0 0 * * *
  • @weekly is 0 0 * * 0
  • @monthly is 0 0 1 * *
  • @yearly (or @annually) is 0 0 1 1 *
  • @reboot runs once when the cron daemon starts

Expressions that aren't standard cron

Some tools use cron-like syntax with extra fields, so an expression copied from one may not work in another:

  • Quartz and Spring add a seconds field at the start, so 0 0 9 * * MON-FRI is 09:00 on weekdays. They also allow ? and letters such as L (last) and W (weekday).
  • AWS EventBridge uses six fields ending with a year, wrapped in cron(...), and needs ? in either the day-of-month or day-of-week field: cron(0 9 ? * MON-FRI *).

The Cron Expression Generator checks standard five-field cron, as used by Linux crontab, Kubernetes and GitHub Actions, and tells you when an expression looks like one of these other formats.

Tools in this guide

  • Cron Expression Generator

    Build a cron schedule from presets or field by field, or paste an expression to read it in plain English, for crontab, Spring, Quartz or AWS. See the next 10 runs in any time zone.

  • Unix Timestamp Converter

    Turn a Unix timestamp into a readable date in any time zone, or a date into a timestamp. Seconds, milliseconds, microseconds and nanoseconds are detected automatically. Convert many at once, or get the start and end of any day, month or year.