Guides / Cron Expressions

How to Write a Cron Expression

5 min read · Scheduling

What is a cron job?

A cron job is a task scheduled to run automatically at specific times or intervals on Unix-like systems. The name comes from Chronos, the Greek god of time. Cron jobs are used to automate backups, send scheduled emails, clean up temporary files, fetch data from APIs, and much more.

A cron expression is the string that defines when the job runs.

The 5-field syntax

A standard cron expression has 5 fields separated by spaces:

┌───────────── minute (0–59)
│ ┌─────────── hour (0–23)
│ │ ┌───────── day of month (1–31)
│ │ │ ┌─────── month (1–12)
│ │ │ │ ┌───── day of week (0–6, Sun=0)
│ │ │ │ │
* * * * *

Special characters

CharacterMeaningExample
*Any / every value* in hour = every hour
,List of values1,3,5 in hour = 1am, 3am, 5am
-Range of values1-5 in dow = Mon to Fri
*/nEvery n units*/10 in minute = every 10 min

Common examples

ExpressionMeaning
* * * * *Every minute
0 * * * *Every hour, at minute 0
0 9 * * *Every day at 9:00 AM
0 9 * * 1Every Monday at 9:00 AM
0 9 * * 1-5Every weekday (Mon–Fri) at 9:00 AM
0 0 1 * *First day of every month at midnight
*/5 * * * *Every 5 minutes
*/15 * * * *Every 15 minutes
0 0,12 * * *Twice daily — midnight and noon
0 0 * * 0Every Sunday at midnight
30 23 * * 5Every Friday at 11:30 PM
0 6 1 1 *January 1st at 6:00 AM

Day of week values

NumberDay
0Sunday
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday

Note: Some systems also accept 7 for Sunday. Both 0 and 7 are valid in most implementations.

6-field cron (with seconds)

Some systems (AWS CloudWatch, Spring, Quartz) use a 6-field cron expression with an additional seconds field at the beginning:

┌─────────── second (0–59)
│ ┌───────── minute (0–59)
│ │ ┌─────── hour (0–23)
│ │ │ ┌───── day of month (1–31)
│ │ │ │ ┌─── month (1–12)
│ │ │ │ │ ┌─ day of week (0–6)
│ │ │ │ │ │
0 * * * * *    ← every minute at second 0

Common mistakes

  • Wrong timezone — cron runs in the server's timezone, which may differ from yours
  • Confusing day-of-week values — always double-check: 0 = Sunday, 1 = Monday
  • Using */1 — this is valid but redundant; just use *
  • Forgetting that both DOM and DOW fields active means OR — if you set both, the job runs when either condition is met

Build and test cron expressions

Use our visual cron builder to create expressions and preview the next scheduled runs.

Cron Builder →