A cron expression looks like a code, but it is really a sentence squeezed into five boxes. "Run the cleanup at half past two every Sunday" is a complete schedule anyone can read; writing an expression from scratch is translating that sentence, one decision at a time, without dropping or adding anything on the way. Most broken schedules are not broken because cron is hard, but because someone filled the boxes from memory and never read the result back.

This guide walks through the translation in field order, builds a real expression decision by decision, and verifies it with the free Cron Expression Builder on Ovatly, which explains any expression back in plain English and lists the next five run times in your own time zone.

Contents

  • Quick answer
  • Start from the sentence, not the fields
  • The five fields and the three kinds of answer
  • How to write and verify an expression, step by step
  • Worked example: a Sunday cleanup at 02:30
  • Limitations and honest notes
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Write your schedule as one plain sentence, then work through the fields in their fixed order: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7, with 0 and 7 both meaning Sunday). For each field, either pin the value your sentence names, use a range or a step when the sentence says "every so often", or write an asterisk when the sentence puts no limit on that field. Then paste the finished expression into the Cron Expression Builder and read the plain-English description and the next five run times. If either one differs from your sentence, the expression is wrong, no matter how neat it looks.

Start from the sentence, not the fields

A schedule sentence has three parts, and each part maps to specific fields:

  • The time of day ("at half past two", "at nine in the morning") becomes the minute and hour fields.
  • Which days ("every Sunday", "on the first of the month", "on weekdays") becomes the day of month and day of week fields.
  • Which part of the year ("in June", "every month") becomes the month field. Most schedules say nothing about the month, meaning an asterisk there.

Writing the sentence first matters because cron cannot hold a thought you skipped. If the sentence does not say which days, you have not decided yet, and guessing is how a Sunday job ends up running daily.

The five fields and the three kinds of answer

Every field accepts the same small set of answers:

  1. A pinned value. One number: minute 30, hour 2, day of week 0 for Sunday.
  2. A range or a step. A range such as 1-5 in day of week means Monday to Friday. A step such as */15 in the minute field means every 15 minutes: the slash form steps through the field's range.
  3. An asterisk. Every value of that field, with no restriction at all.

A hand-written expression is five of those answers in the fixed order, separated by spaces. Two numbering facts cause a steady share of errors: the hour field runs 0-23, so 2 in the morning is 2 and 2 in the afternoon is 14; and day of week starts at 0 for Sunday, with 7 accepted as Sunday too, while 1 is Monday.

How to write and verify an expression, step by step

  1. Write the schedule as a sentence and split it into time of day, which days, and which months.
  2. Fill the minute and hour fields from the time of day. Pin both: an asterisk in either one means the job fires repeatedly.
  3. Fill one day field. If the sentence names days of the month ("the first", "the 15th"), pin day of month and leave day of week as an asterisk. If it names weekdays ("Sundays", "weekdays"), pin day of week and leave day of month as an asterisk.
  4. Fill the month field: a number or range if the sentence limits the season, an asterisk if it runs all year.
  5. Open the Cron Expression Builder and paste your finished expression into the lower field.
  6. Read the plain-English description the Cron Expression Builder gives back and compare it word by word with your sentence. Then scan the next five run times and confirm the dates match: the right days, the right clock time, the right gaps.
  7. Only when both agree with the sentence is the expression ready to save anywhere.

Worked example: a Sunday cleanup at 02:30

The sentence: "Run the cleanup at half past two every Sunday, all year."

Field by field:

  • Minute: half past the hour is minute 30. Pin it: 30.
  • Hour: two in the morning on a 24-hour clock is 2.
  • Day of month: the sentence names no day of the month, so asterisk.
  • Month: all year, so asterisk.
  • Day of week: Sunday is 0.

Assembled in order, the expression is:

30 2 * * 0

Now verify rather than trust. Pasting 30 2 * * 0 into the builder should produce a description matching the sentence, and the next-run list should show dates exactly seven days apart, each a Sunday, each at 02:30 in your local time. If the list showed consecutive days, the day of week field would be wrong; if it showed 14:30, the hour was written on a 12-hour assumption.

One change shows the method's edge: running the same cleanup on the first Sunday and also on the 1st of the month is not a single-field edit, because restricting both day fields triggers the either-or behavior described below. Wanting "and" between two day conditions means the schedule needs two separate expressions.

Limitations and honest notes

The builder covers standard five-field cron only. Seconds and year fields from Quartz-style schedulers are not included, so an expression copied from a Quartz system has to be reduced to five fields before this method applies, and any schedule needing second-level timing is outside what standard cron expresses.

The next-run list is calculated in your browser's local time zone. Servers usually run cron in UTC, so the dates you verify are correct as a pattern, but the clock times land in whatever zone the scheduler uses. A verified 30 2 * * 0 fires at 02:30 on the server's clock, not necessarily yours.

Standard cron also has no memory and no conditions: it cannot express "the first Sunday of the month" or "the last day of the month", and it does not skip a run because the previous one is still going. Such schedules need two expressions, a wrapper script, or a different scheduler.

Common mistakes

  • Filling fields in sentence order. English says "Sunday at 2:30"; cron wants minute first and day of week last. Translating in spoken order scrambles the schedule completely.
  • Writing the hour on a 12-hour clock. 2 is 02:00. An afternoon job needs 14, and there is no AM or PM marker.
  • Leaving the minute as an asterisk. A time like "at two o'clock" pins both fields. An asterisk minute turns a daily job into one that fires sixty times in the chosen hour.
  • Counting Sunday as 1. Sunday is 0 (or 7). Day of week 1 is Monday, so this off-by-one shifts a weekly job by a full day.
  • Restricting both day fields to narrow the schedule. The two fields combine as either-or, so the job fires on more days, not fewer.

FAQs

What order do the five fields go in? 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 are Sunday). The order never changes, and reading an expression always starts at the minute.

What does an asterisk mean in a field I do not care about? It means every value of that field. A schedule that runs daily at a set time still needs all five fields, so the day of month, month and day of week fields are filled with asterisks rather than left blank.

How do I check an expression I wrote by hand? Paste it into the lower field of the Cron Expression Builder. It explains the expression back to you in plain English and lists the next five run times in your local time zone, so a field mistake shows up as a wrong sentence or a wrong date.

Can I write an expression that runs at a specific second? Not in standard five-field cron, and the builder does not include seconds or year fields either. Those belong to Quartz-style schedulers. The smallest unit a standard expression can pin is the minute.

Why does my expression fire on more days than I set? Probably both day fields are restricted. Under standard cron behavior, when day of month and day of week are both restricted, a day matches if either field matches. Keep one of the two as an asterisk unless you want that wider schedule.

Conclusion

Writing a cron expression from scratch is translation, not memorization: one complete sentence, five fields in a fixed order, and a verification pass that reads the result back to you. The how to schedule a cron job to run every hour guide takes the simplest schedule of all and shows why even it has a wrong way to be written, and the full set of guides for this category lives in the Developer Tools guides archive.