What is a cron expression?

A cron expression is five fields that say when a job runs. From left to right they are minute, hour, day of month, month and day of week.

Field Allowed values Example
Minute 0 to 59 30
Hour 0 to 23 9
Day of month 1 to 31 1
Month 1 to 12 6
Day of week 0 to 7, where 0 and 7 are Sunday 1-5

A star means every value. A slash means every so many, a comma lists values and a hyphen gives a range.

Common cron schedule examples

Schedule Expression
Every 5 minutes */5 * * * *
Every hour 0 * * * *
Every day at midnight 0 0 * * *
Weekdays at 9 am 0 9 * * 1-5
Every Monday at 8.30 am 30 8 * * 1
First day of each month 0 0 1 * *

Why does a cron job run on the wrong day?

Check the two day fields. In standard cron, if you set both day of month and day of week, the job runs when either one matches. So 0 0 13 * 5 runs on every 13th and on every Friday. It doesn't mean Friday the 13th.

Time zone is the other usual suspect. A server may run in UTC while you're reading local time. Daylight saving changes can also skip or repeat a job near 2 am.

Why isn't my cron job running?

  • The command needs a full path, since cron has a small environment
  • The script isn't executable
  • Percent signs in the command need a backslash
  • The schedule uses six fields, and your system expects five

Six field formats such as Quartz add seconds at the start. The generator flags them. If your job parses logs, test the pattern in the regex tester. For tokens that expire between runs, inspect them in the JWT decoder.