This topic was translated by AI and is currently in queue for revision by our editors. Alibaba Cloud does not guarantee the accuracy of AI-translated content. Request expedited revision

Detailed explanation of CRON expressions

Updated at: 2025-03-21 19:01

A CRON expression is a string comprising 5 or 6 space-separated fields, each representing a specific time element.

CRON supports the following two syntax formats:

  • Second Minute Hour Date Month Day-of-week Year

  • Second Minute Hour Date Month Day-of-week

Note

The CRON expression for the IDaaS identity provider requires an interval of more than 1 hour. To ensure data synchronization meets your expectations, it is advisable to control the interval appropriately.

Allowed values for each field

Field

Allowed values

Allowed special characters

Remarks

Field

Allowed values

Allowed special characters

Remarks

Second

0~59

- * /

-

Minute

0~59

- * /

-

Hour

0~23

- * /

-

Date

1~31

- * ? / L W C

-

Month

1~12

JAN-DEC - * /

-

Day-of-week

1~7

SUN-SAT - * ? / L C #

1 indicates Sunday, 2 indicates Monday, and so on

Year (optional)

Empty, 1970~2099

, - * /

Automatically generated, the tool does not display this value

Meaning of special characters

Character

Meaning

Example

Character

Meaning

Example

*

Matches any value in the field

Using * in the minute field means the event triggers every minute.

Matches any value in the field, but is only used in the date and day-of-week fields to avoid conflict.

To schedule a trigger for the 20th of each month, regardless of the day of the week, the correct syntax is: 13 13 15 20 * ?. Because the date field specifies the 20th, the day-of-week field must use ? rather than *. Using * in the last field would indicate a trigger on any day of the week, which would conflict with the specified date of the 20th and result in an incorrect expression.

-

Specifies a range of values

Using 5-20 in the minute field means it triggers every minute from the 5th to the 20th minute.

/

Triggers at fixed intervals starting from a specified time

Using 5/20 in the minute field means it triggers at the 5th minute and then every 20 minutes thereafter, such as at 5, 25, 45, etc.

,

Lists specific enumeration values

Using 5,20 in the minute field means it triggers at the 5th and 20th minutes.

L

Indicates the last occurrence within a period, used in day and day-of-week fields

Using 5L in the day-of-week field means it triggers on the last Thursday of the month.

W

Indicates the nearest weekday to a given date, used only in the day field

Using 5W in the day field, if the 5th is a Saturday, it triggers on the nearest weekday, Friday the 4th. If the 5th is a Sunday, it triggers on Monday the 6th. If the 5th is a weekday, it triggers on the 5th.

LW

Combines L and W to indicate the last weekday of a month

#

Specifies the nth occurrence of a day in a month, used only in the day-of-week field

Using 4#2 in the day-of-week field means it triggers on the second Wednesday of the month, where 4 represents Wednesday and 2 represents the second occurrence.

Examples

  • 0 */1 * * * ?: Executes every minute

  • 0 0 2 1 * ?: Executes at 2 AM on the 1st of every month

  • 0 15 10 ? * MON-FRI: Executes at 10:15 AM every Monday to Friday

  • 0 15 10 ? 6L 2002-2006: Executes at 10:15 AM on the last Friday of every month from 2002 to 2006

  • 0 0 23 * * ?: Executes at 11 PM every day

  • 0 0 1 * * ?: Executes at 1 AM every day

  • 0 0 1 1 * ?: Executes at 1 AM on the 1st of every month

  • 0 0 23 L * ?: Executes at 11 PM on the last day of every month

  • 0 0 1 ? * L: Executes at 1 AM every Sunday

  • 0 26,29,33 * * * ?: Executes at 26, 29, and 33 minutes past the hour

  • 0 0 0,13,18,21 * * ?: Executes at midnight, 1 PM, 6 PM, and 9 PM every day

  • 0 0 10,14,16 * * ?: Executes at 10 AM, 2 PM, and 4 PM every day

  • 0 0/30 9-17 * * ?: Executes every half hour during working hours from 9 AM to 5 PM

  • 0 0 12 ? * WED: Executes at noon every Wednesday

  • 0 0 12 * * ?: Triggers at noon every day

  • 0 15 10 ? * *: Triggers at 10:15 AM every day

  • 0 15 10 * * ?: Triggers at 10:15 AM every day

  • 0 15 10 * * ? *: Triggers at 10:15 AM every day

  • 0 15 10 * * ? 2005: Triggers at 10:15 AM every day in 2005

  • 0 * 14 * * ?: Triggers every minute from 2 PM to 2:59 PM every day

  • 0 0/5 14 * * ?: Triggers every 5 minutes from 2 PM to 2:55 PM every day

  • 0 0/5 14,18 * * ?: Triggers every 5 minutes from 2 PM to2:55 PM and from 6 PM to 6:55 PM every day

  • 0 0-5 14 * * ?: Triggers every minute from 2 PM to 2:05 PM every day

  • 0 10,44 14 ? 3 WED: Triggers at 2:10 PM and 2:44 PM on Wednesdays in March every year

  • 0 15 10 ? * MON-FRI: Triggers at 10:15 AM from Monday to Friday

  • 0 15 10 15 * ?: Triggers at 10:15 AM on the 15th of every month

  • 0 15 10 L * ?: Triggers at 10:15 AM on the last day of every month

  • 0 15 10 ? * 6L: Triggers at 10:15 AM on the last Friday of every month

  • 0 15 10 ? * 6L 2002-2005: Triggers at 10:15 AM on the last Friday of every month from 2002 to 2005

  • 0 15 10 ? * 6#3: Triggers at 10:15 AM on the third Friday of every month

  • On this page (1)
  • Allowed values for each field
  • Meaning of special characters
  • Examples
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare