cron rules and examples

In spring4 and above, the cron expression contains 6 parameters:
[second] [minute] [hour] [date] [month] [week]
also supports several commonly used special symbols:

*: Indicates that the task is triggered at any time
,: Indicates that the task is triggered at a specified time
-: Indicates that the task is triggered within a period of time
/: Indicates from which moment and how often the task is triggered.
?: Indicates two sub-expressions for the day of the month and the day of the week, indicating that no value is specified.
The specific meaning of cron expression parameters:

Seconds, value range: 0-59, supports *,,,-,/.
Points, value range: 0-59, supports *,,,-,/.
When , the value range is: 0-23, supporting *,,,-,/.
Date, value range: 1-31, supports *,,,-,/. More than seconds? means that if the specified day of the week is triggered, the configured date becomes invalid.
Month, value range: 1-12, supports *,,,-,/.
Day of the week, value range: 1~7, 1 represents Sunday, 6 represents Saturday, and so on. support*,,,-,/,?. More than seconds? means that if the specified date is triggered, the configured weekday becomes invalid.
Examples of common cron expressions:

0 0 0 1 * ? Executed at 0:00 on the 1st of every month
0 0 2 * * ? Executed at 2 am every day
0 0 2 * * ? Executed at 2 am every day
0 0/5 11 * * ? 11:00-11:55 every day , executed every 5 minutes
0 0 18 ? *WED Executed every Wednesday at 6 pm

Guess you like

Origin blog.csdn.net/qq_44543774/article/details/132814108