How Do You Read a Cron Expression by Hand?
Understanding scheduled-task syntax step by step.
Summary
A cron expression has five fields, read left to right: minute, hour, day of month, month, and day of week. An asterisk in any field means 'every.'
Step by step
- Split the expression into five fields: minute, hour, day of month, month, day of week.
- Work out what the number or asterisk in each field means.
- Verify the expression with a visual tool.
- Make sure the server's timezone matches what you expect.
Why it matters
Cron expressions are usually written once and left alone for months. Then a backup runs at an odd hour, or a report never goes out, and someone has to read that line and figure out what it does. When you inherit someone else's server config or chase a bug, reading the expression by hand gives you a quick answer without opening any tool.
Reading the special characters
- A comma means a list: 9,13,17 in the hour field reads as "at 9, 13 and 17."
- A hyphen means a range: 1-5 in the day-of-week field means Monday through Friday.
- A slash means a step: */15 in the minute field means every 15 minutes, so minutes 0, 15, 30 and 45.
- In the day-of-week field, 0 is Sunday. Many systems also accept 7 as Sunday.
Reading an example together
Take 30 2 * * 1-5. The first field is 30, so minute 30. The second is 2, so hour 2. Day of month and month are asterisks, so no restriction there. The last field is 1-5, Monday to Friday. Put together: 2:30 a.m. on every weekday. A good habit is to combine the minute and hour into a clock time first, then look at the day restrictions.
Common mistakes
- Reading day-of-month and day-of-week as "and" when both are set. In classic cron the job runs when either one matches, so read it as "or."
- Thinking * 9 * * * means once a day at 9. With an asterisk in the minute field, it runs every minute from 9:00 to 9:59.
- Reading a six- or seven-field expression as if it had five. Some schedulers add a seconds field at the start or a year at the end, so check which system you're on before assuming the first field is minutes.
- Counting months from 0. They run from 1 to 12.
When to ask for help
If the expression triggers something hard to undo, like charging customers, sending a mass email or deleting data, confirm your reading with whoever wrote it or with the system administrator before changing anything.