How to write cron expressions: fields, examples and testing
A cron expression is a five-field string that tells a Unix-like system when to run a job: every night at 3am, every 15 minutes, or on the first day of each month. Servers use it to schedule backups, reports, clean-ups and data syncs.
The five fields of a cron expression
From left to right the fields are: minute (0–59), hour (0–23), day of month (1–31), month (1–12) and day of week (0–7, where both 0 and 7 mean Sunday). Each field accepts a number, a list such as 1,3,5, a range such as 1–5, a step such as */15, or a combination of them. A bare asterisk means any value.
So 0 3 * * * means minute 0 of hour 3, any day, any month, any weekday — in other words, every day at 3:00. The fields combine with AND logic: a value must match every non-wildcard field to trigger.
- `0 3 * * *` — every day at 3:00 am.
- `*/15 * * * *` — every 15 minutes.
- `0 9 * * 1–5` — 9:00 am on weekdays only.
- `30 2 1 * *` — 2:30 am on the 1st of every month.
Common cron patterns
Most schedules people need are covered by a handful of patterns. Run hourly on the hour: 0 * * * *. Every Sunday at midnight: 0 0 * * 0. Every six hours: 0 */6 * * *. At 8:15 am every Monday: 15 8 * * 1.
Two details catch almost everyone. Some implementations treat day-of-week as 0–6 with Sunday as 7 instead of 0, and many systems run a job only when both day-of-month and day-of-week match rather than either one — so combining both fields rarely does what you expect.
Test before you schedule it
A cron expression is easy to type and easy to get subtly wrong: one character changes a nightly job into an hourly one, and nothing warns you until the load spike. Put the expression into the Cron Expression Tester before you deploy it.
The tester validates each field separately, explains in plain language what the schedule actually means, and prints the next five run times. Those five timestamps are the real test — read them out and confirm they are exactly the moments you intended, then save the expression with confidence.
- Validate the expression field by field.
- Read the plain-language description of the schedule.
- Check the next five run times against your intention.
- Watch the timezone: cron uses server time, not your browser time.

