One Click Answers

Cron expressions explained

Cron is a scheduler found on many servers. You tell it when to run a job with a short expression made of five fields separated by spaces. The format looks cryptic, but there are only a few ideas to learn.

The five fields

Fields in order
PositionFieldAllowed values
1Minute0 to 59
2Hour0 to 23 (0 is midnight, 13 is 1 PM)
3Day of month1 to 31
4Month1 to 12
5Day of week0 to 6, Sunday to Saturday (7 also means Sunday in many versions)

The special characters

  • A star means every value: every minute, every hour and so on.
  • A comma separates a list: 8,17 means at 8 and at 17.
  • A dash gives a range: 1-5 means 1 through 5.
  • A slash gives a step: */15 means every 15.

Examples in plain words

Common expressions
ExpressionMeaning
*/15 * * * *Every 15 minutes
0 9 * * 1-5Every weekday at 9:00 AM
30 2 * * *Every day at 2:30 AM
0 8,17 * * *Every day at 8:00 AM and 5:00 PM
0 0 * * 0Every Sunday at 12:00 AM

Time zones

Cron normally runs on the clock of the machine or service that hosts it, which is often set to UTC. A job set for 9:00 AM runs at 9:00 AM on that machine's clock, not necessarily yours. Check which zone your scheduler uses.

Cron Expression Generator: Build a schedule from plain choices, or paste an expression to read it back in words and see the next run times.

Published by OneClickAnswers.

You might also wonder...

Try it yourself

← All articles

Got another question?

Free, no account. Answers show how they were worked out.