How to Write a Cron Expression (With Examples)
Updated 2026-06-21
A cron expression is five space-separated fields that tell a scheduler when to run a job: minute, hour, day-of-month, month, and day-of-week. To run a task every day at 2:30 AM, you write 30 2 * * *. The asterisk means "every value," so this fires at minute 30 of hour 2, on every day, every month, every weekday.
The five fields, in order
Read a cron line left to right. Each field accepts a number, an asterisk, or a list/range/step:
- Minute — 0 to 59
- Hour — 0 to 23 (24-hour clock, so 2 PM is 14)
- Day of month — 1 to 31
- Month — 1 to 12 (or JAN to DEC)
- Day of week — 0 to 6, where 0 and 7 both mean Sunday (or SUN to SAT)
The special characters are the same in every field. A comma makes a list (1,15 = the 1st and 15th). A hyphen makes a range (9-17 = 9 through 17). A slash makes a step (*/5 = every 5th value). So 0 9-17/2 * * 1-5 means "at minute 0, every 2 hours from 9 to 17, Monday through Friday."
Worked examples you can copy
- Every 15 minutes: */15 * * * *
- Top of every hour: 0 * * * *
- Every day at midnight: 0 0 * * *
- Every Monday at 9 AM: 0 9 * * 1
- First of the month at 6 AM: 0 6 1 * *
- Weekdays at 8:30 AM: 30 8 * * 1-5
- Twice a day, noon and midnight: 0 0,12 * * *
The pitfalls that silently break schedules
The day-of-month and day-of-week fields have a trap. When both are set to something other than an asterisk, most cron implementations treat them as an OR, not an AND. So 0 0 13 * 5 does not mean "Friday the 13th" — it runs on the 13th of the month and on every Friday. If you want a true intersection, you usually can't express it in one line.
Other common mistakes: using 24 for midnight (the valid range is 0 to 23), forgetting that */40 in the minute field jumps 0, 40, then resets at the next hour rather than every 40 minutes evenly, and confusing the local time zone of the server with your own. Always confirm what time zone the scheduler uses.
Verify before you deploy
The safest way to avoid a 3 AM surprise is to see the schedule explained in plain English and check the actual next run times. The Cron Expression Builder does both: pick fields or type an expression, get a sentence describing when it fires, and preview the upcoming run dates so you catch an OR-trap or a wrong hour before it reaches production.
It runs entirely in your browser, so nothing about your jobs is uploaded. Build and double-check your schedule with the Cron Expression Builder.