Allison is coding...

Cron Job Schedule Syntax Explained

A cron job schedule is a string of five (or sometimes six) fields that tells a Unix-like operating system exactly when to execute a command.

The Standard Five-Field Syntax

Each asterisk represents a specific unit of time. The order is always the same:

FieldDefinitionAllowed Values
1Minute0 – 59
2Hour0 – 23 (0 is midnight)
3Day of Month1 – 31
4Month1 – 12 (or JAN-DEC)
5Day of Week0 – 6 (Sunday to Saturday)

Understanding the Symbols

While the asterisk (*) is the most common symbol, there are others that allow for more complex scheduling:

  • * (Asterisk): Every. If you put * in the minute field, it means “every minute.”
  • , (Comma): A list of values. 1,15,30 in the minute field means at the 1st, 15th, and 30th minute.
  • - (Hyphen): A range. 1-5 in the Day of Week field means Monday through Friday.
  • / (Slash): Increments. */10 in the minute field means “every 10 minutes.”

Common Examples

Here is how those symbols look in practice:

  • 0 0 * * *
    Runs at exactly midnight every single day.
  • */15 9-17 * * 1-5
    Runs every 15 minutes during business hours (9 AM to 5 PM), Monday through Friday.
  • 0 12 1 * *
    Runs at noon on the first day of every month.
  • 30 8 * * 0
    Runs every Sunday at 8:30 AM.

A Note on the Sixth Field

In some systems (like Quartz or modern cloud schedulers), there might be a sixth field at the very beginning. This is usually for seconds (0-59). If the string has six parts, always check the documentation for that specific tool, as it usually shifts the other fields to the right.