Cron expressions
This topic describes the syntax rules and usage of Cron expressions in Alibaba Cloud IDaaS EIAM. It helps you correctly configure scheduled tasks.
What is a Cron expression?
A Cron expression is a time expression used to configure scheduled tasks. It is a string that consists of 6 or 7 fields separated by spaces. Each field represents a time unit.
Basic syntax
Cron syntax format:
Seconds Minutes Hours Day of month Month Day of week [Year]Values allowed for each field
Field position
Time unit
Value range
Allowed special characters
1
Seconds
0–59
- * /
2
Minutes
0–59
- * /
3
Hours
0–23
- * /
4
Day of month
1–31
- * ? / L W C
5
Month
1–12 or JAN–DEC
JAN-DEC - * /
6
Day of week
0–7 (both 0 and 7 indicate Sunday) or SUN–SAT
SUN-SAT - * ? / L C #
7 (optional)
Year
Leave blank or use 1970–2199 (optional field).
, - * /
Special characters
Character | Meaning | Description |
* | Indicates any value of the field. | Using * in the Minutes field triggers the event every minute. |
? | Indicates any value of the field. However, it can be used only in the Day of month and Day of week fields because these fields affect each other. | To trigger the schedule on the 20th of each month regardless of the day of the week, use only the following expression: |
- | Indicates a range of values. | Using 5-20 in the Minutes field triggers the event every minute from minute 5 to minute 20. |
/ | Indicates an event that starts at the specified value and then recurs at a fixed interval. | Using 5/20 in the Minutes field triggers the event at minute 5 and then every 20 minutes. It triggers at minutes 5, 25, and 45. |
, | Indicates enumerated values. | Using 5,20 in the Minutes field triggers the event every minute at minutes 5 and 20. |
L | Indicates the last value. This character can appear only in the Day of month and Day of week fields. | Using 5L in the Day of week field triggers the event on the last Thursday. |
W | Indicates a business day (Monday to Friday). This character can appear only in the Day of month field. The system triggers the event on the business day closest to the specified date. | Using 5W in the Day of month field triggers the event on Friday the 4th when the 5th is a Saturday. When the 5th is a Sunday, the event triggers on Monday the 6th. If the 5th is a business day, the event triggers on the 5th. The nearest-match search for W does not cross month boundaries. |
LW | These characters can be used together. They indicate the last business day of a month, that is, the last Friday. | |
# | Indicates the Nth day of the week in a month. This character can appear only in the Day of week field. | Using 4#2 in the Day of week field triggers the event on the second Wednesday of a month. In this expression, 4 indicates Wednesday, and 2 indicates the second occurrence. |
Common examples
Cron expressions in the IDaaS identity provider require an interval of at least 1 hour. Set the interval appropriately so that the data synchronization frequency meets your expectations.
Example | Description |
| Runs every 2 hours. |
| Runs at 02:00 on the 1st of each month. |
| Runs the job at 10:15 every day from Monday to Friday. |
| Runs at 23:00 every day. |
| Runs at 01:00 every day. |
| Runs at 01:00 on the 1st of each month. |
| Runs at 23:00 on the last day of each month. |
| Runs at 01:00 every Sunday. |
| Runs at 00:00, 13:00, 18:00, and 21:00 every day. |
| Runs at 10:00, 14:00, and 16:00 every day. |
| Runs at 12:00 every Wednesday. |
| Triggers at 12:00 every day. |
| Triggers at 10:15 every day. |
| Triggers at 10:15 every day. |
| Triggers at 10:15 every day. |
| Triggers at 10:15 every day in 2025. |
| Triggers at 10:15 on the 15th of each month. |
| Triggers at 10:15 on the last day of each month. |
| Triggers at 10:15 on the last Friday of each month. |
| Triggers at 10:15 on the last Friday of each month from 2025 to 2026. |
| Triggers at 10:15 on the third Friday of each month. |
You can adjust the time parameters in these examples, including the year, based on your requirements.