How to Read and Write a Cron Expression

How to Read and Write a Cron Expression

A cron expression looks cryptic at first, but it is just five fields that say when a job should run. Once you know the order of the fields and a handful of special characters, you can read any schedule at a glance. Here is how it works.

The five fields

A standard cron expression has five fields, separated by spaces, always in this order:

* * * * *
| | | | |
| | | | +-- day of week  (0-6, Sunday is 0)
| | | +---- month        (1-12)
| | +------ day of month (1-31)
| +-------- hour         (0-23)
+---------- minute       (0-59)

So the leftmost field is the minute and the rightmost is the day of the week. Each field accepts a value inside its own range, and a job runs only when every field matches the current time. If you ever forget the order, paste the expression into the Cron Expression Explainer and it spells out each field in plain English.

The special characters

Four characters do most of the work across all five fields:

  • * (any): matches every value for that field. A * in the hour field means “every hour.”
  • , (list): picks several specific values. 1,15 in the day-of-month field means the 1st and the 15th.
  • - (range): covers a span. 1-5 in the day-of-week field means Monday through Friday.
  • / (step): repeats at an interval. */15 in the minute field means every 15 minutes, and you can combine it with a range like 0-30/10.

Worked examples

Reading a few real schedules makes the pattern click:

  • 0 0 * * * runs daily at midnight. Minute 0, hour 0, any day, any month, any weekday.
  • */15 * * * * runs every 15 minutes, all day, every day.
  • 0 9 * * 1 runs at 9am every Monday. Minute 0, hour 9, day-of-week 1.

To build your own, start from the smallest unit. Decide the minute, then the hour, then the wider date and weekday rules. Then check it:

  1. Open the Cron Expression Explainer.
  2. Paste your five-field expression.
  3. Read the plain-English description and the next run times to confirm it matches what you intended.

Everything runs in your browser, so your schedules and any details you paste stay on your device.

WP-Cron is not system cron

If you work with WordPress, this is the catch. WP-Cron uses the same field idea but it is not real system cron. It does not run on a clock kept by the operating system. Instead, it fires only when someone visits your site, then checks whether any scheduled task is due. On a low-traffic site, a job set for midnight may not run until the first visitor shows up hours later. On a busy site it can fire too often.

For reliable timing, many developers disable WP-Cron and trigger wp-cron.php from a real system cron job at a fixed interval. The expression syntax above is exactly what you would use in that crontab entry.

Read it left to right, minute first, and any cron expression stops being a mystery.

← All posts