This topic describes how to set cron expressions.
Cron is suitable for recurring tasks, routine maintenance, and one-time tasks that must run at a specific time. A cron expression is a string that represents a time schedule. The string is divided into six fields separated by spaces, in the format X X X X X X. In this format, X is a placeholder for a field. If a field contains multiple values, use a comma (,) to separate them. Each field can contain a specific value or a special character that has a logical meaning.
Field values
The following table describes the valid values and supported special characters for each of the six fields in a cron expression.
Field | Required | Value range | Special characters |
Second | Yes | [0, 59] | Not supported |
Minute | Yes | [0, 59] | Limited support for commas (,) and forward slashes (/). If you use a comma, the interval between the numbers must be 30 minutes or more. If you use a forward slash, the number after the slash must be 30 or more. |
Hour | Yes | [0, 23] | * , - / |
Date | Yes | [1, 31] | * , - / ? L |
Month | Yes | [1, 12] or [JAN, DEC] | * , - / |
Week | Yes | [1, 7] or [SUN, SAT]. If you use the | * , ? |
Special characters
Each field in a cron expression supports special characters. Each special character has a specific meaning.
Special character | Meaning | Example |
| All possible values. | In the Month field, |
| Enumeration values. | In the Minute field, |
| Scope | In the Day-of-month field, |
| Specifies an increment for a value. | In the Day-of-month field, |
| Indicates no specific value. This character is supported only in the Day-of-month and Day-of-week fields. | When a value is specified for either the Day-of-month or Day-of-week field, set the other field to |
| Stands for 'last' and means the last day. This character is supported only in the Day-of-month field. Note When you specify the | In the Day-of-month field, |
Examples
The following table shows examples of cron expressions.
Example | Description |
| Runs the task at 10:15 every day. |
| Runs the task at 10:15 every day. |
| Runs the task at 12:00 (noon) every day. |
| Runs the task at 10:00, 14:00, and 16:00 every day. |
| Runs the task every 40 minutes from 09:00 to 17:00 every day. |
| Runs the task at 12:00 (noon) every Wednesday. |
| Runs the task at 10:15 on the 15th of every month. |
| Runs the task at 10:15 on the last day of every month. |
| Runs the task at 14:00 and 14:30 every Wednesday in March. |