Cron expressions define schedules for recurring tasks, routine maintenance, and one-time jobs.
A cron expression is a time-based string of six space-separated fields in the format X X X X X X, where each X represents a field value. Separate multiple values in a single field with a comma (,). Each field accepts a specific value or a special character.
Fields and values
The following table describes each field, its allowed values, and supported special characters.
|
Field |
Required |
Value range |
Special character |
|
Second |
Yes |
[0, 59] |
Not supported |
|
Minute |
Yes |
[0, 59] |
Comma-separated values must be at least 30 minutes apart. Forward-slash increments must be 30 or greater. |
|
Hour |
Yes |
[0, 23] |
* , - / |
|
day-of-month |
Yes |
[1, 31] |
* , - / ? L |
|
Month |
Yes |
[1, 12] or [JAN, DEC] |
* , - / |
|
day-of-week |
Yes |
[1, 7] or [SUN, SAT]. For the [1, 7] format, |
* , ? |
Special characters
The following special characters are supported in cron expression fields.
|
Special character |
Description |
Example |
|
|
Matches all values in the field. |
In the Month field, |
|
|
Lists multiple discrete values. |
In the Minute field, |
|
|
Defines a contiguous range of values. |
In the day-of-month field, |
|
|
Defines a step interval. |
In the day-of-month field, |
|
|
No specific value. Valid only in the day-of-month and day-of-week fields. |
The day-of-month and day-of-week fields are mutually exclusive. If you specify a value in one of these fields, you must use a |
|
|
Stands for “last.” Only supported in the day-of-month field, meaning the last day of the month. Note: Do not combine |
In the day-of-month field, |
Examples
The following table shows common cron expression patterns.
|
Example |
Description |
|
|
Runs a task at 10:15 AM every day. |
|
|
Runs a task at 10:15 AM every day. |
|
|
Runs a task at 12:00 PM (noon) every day. |
|
|
Runs a task at 10:00 AM, 2:00 PM, and 4:00 PM every day. |
|
|
Runs a task at 0 and 40 minutes past the hour, every day, from 9:00 AM to 5:59 PM. |
|
|
Runs a task at 12:00 PM (noon) every Wednesday. |
|
|
Runs a task at 10:15 AM on the 15th of every month. |
|
|
Runs a task at 10:15 AM on the last day of every month. |
|
|
Runs a task at 2:00 PM and 2:30 PM on every Wednesday in March. |
|
|
Runs a task at 1:00 AM on the first Wednesday of every month. |