GameParticles
Developer

Cron Expression Cheat Sheet With Real Examples

Cron syntax on one page: the five fields, the four operators, copy-ready schedules, and the gotchas around day-of-week OR logic, DST and nonstandard variants.

Updated

A cron expression is five space-separated fields: minute, hour, day of month, month, day of week. 0 9 * * 1-5 means 09:00 every weekday. * means every value, , lists values, - gives a range, and / sets a step. That is most of the syntax; the rest of this page is examples and the gotchas.

The five fields

In order, with their allowed ranges:

  1. Minute: 0-59
  2. Hour: 0-23 (24-hour clock)
  3. Day of month: 1-31
  4. Month: 1-12 or JAN-DEC
  5. Day of week: 0-6 where 0 is Sunday (7 also means Sunday on most systems), or SUN-SAT

The expression fires when the current time matches all fields, with one exception covered below. Times are evaluated in the timezone of the machine or service running the scheduler, which is usually UTC on servers and in containers.

Operators

  • * any value. * * * * * is every minute.
  • , list. 0 9,17 * * * is 09:00 and 17:00.
  • - range. 0 9-17 * * * is the top of every hour from 09:00 through 17:00, nine runs.
  • / step. */15 * * * * is every 15 minutes: :00, :15, :30, :45. 0 */6 * * * is every six hours. Steps can start from an offset: 5/15 in the minute field means :05, :20, :35, :50.

Operators combine: 0 8-18/2 * * 1-5 is every two hours from 08:00 to 18:00 on weekdays.

Real examples

  • * * * * * every minute
  • */5 * * * * every 5 minutes
  • 0 * * * * every hour, on the hour
  • 30 * * * * every hour at :30
  • 0 0 * * * daily at midnight
  • 0 3 * * * daily at 03:00, the classic backup slot
  • 0 9 * * 1-5 weekdays at 09:00
  • 0 0 * * 0 weekly, Sunday midnight
  • 0 0 * * 1 weekly, Monday midnight
  • 0 0 1 * * first day of every month at midnight
  • 0 0 1 1 * once a year, January 1
  • 0 0 1 */3 * quarterly: Jan 1, Apr 1, Jul 1, Oct 1
  • 0 9,13,17 * * * three times a day
  • 0 22 * * 1-5 weeknights at 22:00
  • 0 0 * * 6,0 Saturday and Sunday at midnight
  • 15 2 * * * 02:15 daily, offset from the top of the hour
  • 0 0 */2 * * every other day, roughly; the step resets on the 1st, so a 31-day month ends with back-to-back runs

Building one of these by hand is easy. Checking that it does what you meant is where the Cron Expression Builder helps: it turns any expression into a plain English sentence and lists the next five run times.

The gotchas

Day of month and day of week are OR, not AND

This is the most surprising rule in cron. If both day fields are restricted, the job runs when either matches. 0 0 13 * 5 runs on the 13th of every month and on every Friday, not only on Friday the 13th. There is no standard cron syntax for "the 13th only if it is a Friday"; do that check inside the script.

Last day of the month

Standard cron has no L. 0 0 28-31 * * fires up to four times. The common workaround is to run daily and let the script check whether date -d tomorrow +%d equals 01. Quartz (Java) and some cloud schedulers extend the syntax with L, W and #, but those expressions will not run on a Linux crontab.

Daylight saving time

A job at 0 2 * * * in a timezone with DST will be skipped on the spring-forward night and run twice on the fall-back night. Schedule servers in UTC, or choose hours that never fall in the transition window.

Nonstandard variants

  • Linux crontab accepts @hourly, @daily, @weekly, @monthly, @yearly and @reboot.
  • Quartz, Spring and some AWS services use six or seven fields, adding seconds at the front and an optional year at the end. 0 0 9 * * ? is Quartz for daily at 09:00; the ? means "no specific value" and is required in one of the two day fields.
  • GitHub Actions and Kubernetes CronJobs use the standard five fields in UTC. GitHub also documents that the shortest allowed interval is five minutes and that jobs may start late at busy times.
Cron has no memory. If the machine is off or the container is not running at the scheduled minute, that run is simply missed. Use a job queue or a scheduler with catch-up semantics if every run matters.

Checking your schedule

The next-run list is the fastest sanity check. If the first five times are not what you pictured, the expression is wrong. For a job that writes timestamps into logs or a database, convert the recorded epoch values with the Unix timestamp converter and compare them against the intended schedule; a one-hour drift after a DST change is a common find.

To measure how far apart two runs really were, the Duration Calculator gives the exact gap in days, hours and minutes between two timestamps.

Other schedule and formatting helpers are in the developer category.

Try it

Type or build an expression in the Cron Expression Builder, read the English summary, and confirm the next five run times before it goes into a crontab, a CI workflow or a CronJob manifest.

Tools in this guide

Frequently asked questions

What does 0 0 * * * mean in cron?

Minute 0 of hour 0 on every day, every month, every weekday: in other words, daily at midnight in the scheduler's timezone.

How do I run a cron job every 5 minutes?

Use */5 in the minute field: */5 * * * *. The step operator starts at 0, so it fires at :00, :05, :10 and so on.

Why does my cron job run on extra days when I set both day fields?

In standard cron, day of month and day of week are combined with OR, not AND. 0 0 13 * 5 runs on the 13th of every month and also on every Friday.

What timezone does cron use?

The timezone of the host or service running the scheduler. Servers, containers, GitHub Actions and Kubernetes CronJobs default to UTC unless configured otherwise.

More developer guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵