Guides

Cron Expressions Explained, With Examples

Learn the five fields of a cron schedule, the special characters, common examples, the day-of-month and day-of-week trap, and how to test a schedule before it runs.

The five fields

A standard crontab schedule has five fields separated by spaces, followed by the command to run:

  • Minute: 0 to 59
  • Hour: 0 to 23
  • Day of the month: 1 to 31
  • Month: 1 to 12, or JAN to DEC
  • Day of the week: 0 to 7, or SUN to SAT, where both 0 and 7 mean Sunday

A job runs at every minute that matches all the fields. So 30 2 * * * means minute 30 of hour 2 on any day: 02:30 every night.

Special characters

Four characters do most of the work:

  • * means every value in the field.
  • A comma makes a list: 0,30 in the minute field means on the hour and at half past.
  • A hyphen makes a range: 9-17 in the hour field means 09:00 to 17:59.
  • A slash adds a step: */15 means every 15th value starting from the lowest, so minutes 0, 15, 30 and 45; 0-30/10 means 0, 10, 20 and 30.

Many systems also accept shortcuts such as @hourly, @daily, @weekly, @monthly and @yearly, which stand for 0 * * * *, 0 0 * * *, 0 0 * * 0, 0 0 1 * * and 0 0 1 1 *.

Common schedules

These cover most everyday jobs:

  • Every 5 minutes: */5 * * * *
  • Every hour at half past: 30 * * * *
  • Every night at 02:00: 0 2 * * *
  • Weekdays at 09:00: 0 9 * * 1-5
  • Sundays at 03:30: 30 3 * * 0
  • The first day of every month at midnight: 0 0 1 * *
  • The first day of each quarter: 0 0 1 1,4,7,10 *

Ranges include their last value, which surprises people: */15 9-17 * * 1-5 runs at 09:00 and every 15 minutes until 17:45, not until 17:00.

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

When both day fields are restricted, classic cron runs the job if either one matches, not only when both do. The schedule 0 0 1,15 * 1 therefore runs at midnight on the 1st and the 15th of every month and also every Monday.

If you meant “the 1st of the month, but only when it is a Monday”, cron cannot express that directly. The usual workaround is to schedule every Monday and have the script check the date itself. When only one of the two day fields is restricted and the other is *, the restricted one alone decides.

Time zones and daylight saving

Cron uses the time zone of the server, or the CRON_TZ setting on systems that support it. Many servers run in UTC, which avoids daylight saving surprises: in a local time zone, a job at 02:30 can be skipped on the night the clocks spring forward or run twice when they fall back, depending on the cron implementation.

When a team works across regions, write schedules in UTC and convert the run times for people with the UTC time converter. Log files and APIs often record times as Unix timestamps, which the Unix timestamp converter turns back into dates.

Testing a schedule before you deploy

Before you rely on a schedule, read it back field by field and list its next few run times. The cron expression explainer does both: for */15 9-17 * * 1-5 starting at 08:00 UTC on Monday 2 November 2026, it lists 09:00, 09:15, 09:30, 09:45 and 10:00 UTC.

A few habits prevent most cron problems: use full paths in commands, because cron runs with a minimal environment; send the output to a log file so failures are visible; and make jobs safe to run twice, in case a run overlaps the next one or is repeated by hand.

Common questions

How do I run a job every 90 minutes?

One line cannot do it, because 90 is not a whole number of hours. Use two lines: 0 0-21/3 * * * and 30 1-22/3 * * *, which together run at 00:00, 01:30, 03:00, 04:30 and so on.

Can cron run a job every 30 seconds?

Not with standard cron, whose smallest unit is one minute. Some schedulers have a seconds field; with plain cron, a common workaround is a script that runs twice per minute with a pause in between.

What does @reboot do?

On many cron implementations it runs the command once when the system starts. It is not a time schedule, so it has no next run times.

Last updated:

Useful next steps