当前位置:网站首页>Cronexpression expression explanation and cases
Cronexpression expression explanation and cases
2022-06-30 09:25:00 【LongtengGensSupreme】
1. cron Expression format :
{ Number of seconds } { minute } { Hours } { date } { month } { week } { year ( May be empty )}
2. cron The expressions are interpreted as :
{ Number of seconds } ==> Allowed value range : 0~59 , Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" Represents every 1 Second trigger ;
"," Represents a trigger in a specified number of seconds , such as "0,15,45" representative 0 second 、15 The second and 45 The task is triggered in seconds
"-" Represents a trigger within a specified range , such as "25-45" For from 25 Seconds start to trigger to 45 Second end trigger , every other 1 Second trigger 1 Time
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "0"), The following value represents the offset , such as "0/20" perhaps "*/20" For from 0 Two seconds to start , every other 20 Second trigger 1 Time , namely 0 Second trigger 1 Time ,20 Second trigger 1 Time ,40 Second trigger 1 Time ;"5/20" representative 5 Second trigger 1 Time ,25 Second trigger 1 Time ,45 Second trigger 1 Time ;"10-45/20" On behalf of the [10,45] Inner stepping 20 Second hit time trigger , namely 10 Second trigger 1 Time ,30 Second trigger 1 Time
{ minute } ==> Allowed value range : 0~59 , Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" Represents every 1 Minutes to trigger ;
"," Represents triggering in a specified minute , such as "10,20,40" representative 10 minute 、20 Minutes and 40 The task is triggered in minutes
"-" Represents a trigger within a specified range , such as "5-30" For from 5 Minutes start to trigger to 30 The minute is over Hair , every other 1 Minutes to trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "0"), The following value represents the offset , such as "0/25" perhaps "*/25" For from 0 minutes , every other 25 Minutes to trigger 1 Time , namely 0 Minutes to trigger 1 Time , The first 25 Minutes to trigger 1 Time , The first 50 Minutes to trigger 1 Time ;"5/25" representative 5 Minutes to trigger 1 Time ,30 Minutes to trigger 1 Time ,55 Minutes to trigger 1 Time ;"10-45/20" On behalf of the [10,45] Inner stepping 20 Minute hit time trigger , namely 10 Minutes to trigger 1 Time ,30 Minutes to trigger 1 Time
{ Hours } ==> Allowed value range : 0~23 , Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" Represents every 1 Hours trigger ;
"," Represents triggering at a specified point in time , such as "10,20,23" representative 10 O 'clock 、20 O'clock and 23 Click trigger task
"-" Represents a trigger within a specified period of time , such as "20-23" For from 20 It starts to trigger to 23 Point end trigger , every other 1 Hours trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "0"), The following value represents the offset , such as "0/1" perhaps "*/1" For from 0 It starts to trigger , every other 1 Hours trigger 1 Time ;"1/2" For from 1 It starts to trigger , After every 2 Trigger once per hour ;"19-20/2" The expression will only be in 19 Some trigger
{ date } ==> Allowed value range : 1~31 , Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" It's a daily trigger ;
"?" And { week } Mutually exclusive , It means that if it is clearly specified that { week } Trigger , said { date } meaningless , So as not to cause Conflict and chaos
"," Represents a trigger on a specified date , such as "1,10,20" representative 1 Number 、10 Number and 20 This is the number one 3 God trigger
"-" Represents a trigger within a specified date range , such as "10-15" For from 10 It's starting to trigger 15 The end of the number one triggers , every other 1 God trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "1"), The following value represents the offset , such as "1/5" perhaps "*/5" For from 1 It's starting to fire , every other 5 God trigger 1 Time ;"10/5" For from 10 It's starting to fire , After every 5 Once a day ;"1-10/2" The expression means in [1,10] Within the scope of , every other 2 God trigger , namely 1 Number ,3 Number ,5 Number ,7 Number ,9 No. triggers
"L" If { date } If it's "L", That means the last day of the month triggers
"W " It means to trigger on the nearest working day of the month , The so-called recent working day , That is the shortest distance from the day to the working day , If that day is a working day , Then the distance is 0; The so-called saying of this month , I just can't get the latest working day across the month , Even before / The last day of the following month / The first day does satisfy the most recent working day ; therefore ,"LW" It means the last working day of the month triggers ,"W" Strong dependence on { month }
"C" Trigger according to the calendar , Because of less use , No explanation for the moment
{ month } ==> Allowed value range : 1~12 (JAN-DEC), Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" It means every month ;
"," Represents a trigger in a specified month , such as "1,6,12" representative 1 month 、6 Month and 12 Month triggers mission
"-" Represents a trigger within a specified range of months , such as "1-6" For from 1 The month begins to trigger to 6 The end of the month triggers , every other 1 Three months to trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "1"), The following value represents the offset , such as "1/2" perhaps "*/2" For from 1 The month starts to trigger , every other 2 Three months to trigger 1 Time ;"6/6" For from 6 The month starts to trigger , After every 6 Once a month ;"1-6/12" The expression means every year 1 Month triggers
{ week } ==> Allowed value range : 1~7 (SUN-SAT),1 For Sunday ( The first day of the week ), And so on ,7 On behalf of Saturday ( The last day of the week ), Null values are not allowed , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" It means every week ;
"?" And { date } Mutually exclusive , It means that if it is clearly specified that { date } Trigger , said { week } meaningless , So as not to cause conflict and confusion
"," On behalf of the appointed week to trigger , such as "1,3,5" For Sunday 、 Tuesday and Thursday trigger
"-" Represents triggering within the specified week range , such as "2-4" Representatives trigger from Monday to Wednesday , every other 1 God trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "1"), The following value represents the offset , such as "1/3" perhaps "*/3" It's on Sunday , every other 3 God trigger 1 Time ;"1-5/2" The expression means in [1,5] Within the scope of , every other 2 God trigger , It's Sunday 、 Tuesday 、 Thursday triggers
"L" If { week } If it's "L", That means the last day of the week triggers , It's Saturday ,L= 7 perhaps L = SAT, therefore ,"5L" It means the last Thursday of the month
"#" Used to specify a specific number of weeks ,"#" The front represents the week ,"#" The following represents the week of the month , such as "2#2" Monday of the second week of this month ,"5#3" It means Thursday of the third week of this month , therefore ,"5L" This form is just "#" It's just a special form of
"C" Trigger according to the calendar , Because of less use , No explanation for the moment
{ year } ==> Allowed value range : 1970~2099 , Allow null , If the value is illegal , The scheduler will throw SchedulerException abnormal
"*" It means every year ;
"," It means that it is triggered only in the specified year , such as "2011,2012,2013" representative 2011 year 、2012 Years and 2013 Year trigger mission
"-" Represents a trigger within the specified year range , such as "2011-2020" For from 2011 It began to trigger to 2020 The end of the year triggers , every other 1 Year trigger
"/" Represents trigger step (step),"/" The preceding values represent the initial values ("*" equivalent "1970"), The following value represents the offset , such as "2011/2" perhaps "*/2" For from 2011 It's starting to trigger , every other 2 Year trigger 1 Time
Be careful : except { date } and { week } have access to "?" To achieve mutual exclusion , Beyond expressing meaningless information , Other placeholders should have specific time meanings , And the dependence is : year -> month -> date ( week )-> Hours -> minute -> Number of seconds
3. cron The powerful charm of expression lies in its flexible horizontal and vertical combination and simple syntax , use cron Expressions can write almost any time point you want to trigger
Classic case :
"30 * * * * ?" Trigger the mission every half minute
"1 0 0 * * ?" Every day 0 when 0 branch 0 Execute the task in seconds
"30 10 * * * ?" Hourly 10 branch 30 Second trigger task
"30 10 1 * * ?" Every day 1 spot 10 branch 30 Second trigger task
"30 10 1 20 * ?" monthly 20 Number 1 spot 10 branch 30 Second trigger task
"30 10 1 20 10 ? *" Every year, 10 month 20 Number 1 spot 10 branch 30 Second trigger task
"30 10 1 20 10 ? 2011" 2011 year 10 month 20 Number 1 spot 10 branch 30 Second trigger task
"30 10 1 ? 10 * 2011" 2011 year 10 Every day, every month 1 spot 10 branch 30 Second trigger task
"30 10 1 ? 10 SUN 2011" 2011 year 10 Every Sunday every month 1 spot 10 branch 30 Second trigger task
"15,30,45 * * * * ?" Every time 15 second ,30 second ,45 The task is triggered in seconds
"15-45 * * * * ?" 15 To 45 Seconds , Every second a mission is triggered
"15/5 * * * * ?" Every minute of every minute 15 Seconds to trigger , every other 5 Second trigger once
"15-30/5 * * * * ?" Every minute 15 Seconds to 30 It starts to fire in seconds , every other 5 Second trigger once
"0 0/3 * * * ?" At the end of every hour 0 branch 0 Seconds to start , Trigger every three minutes
"0 15 10 ? * MON-FRI" Monday to Friday 10 spot 15 branch 0 Second trigger task
"0 15 10 L * ?" On the last day of every month 10 spot 15 branch 0 Second trigger task
"0 15 10 LW * ?" On the last working day of every month 10 spot 15 branch 0 Second trigger task
"0 15 10 ? * 5L" On the last Thursday of every month 10 spot 15 branch 0 Second trigger task
"0 15 10 ? * 5#3" On Thursdays of the third week of every month 10 spot 15 branch 0 Second trigger task
边栏推荐
- Abstract factory pattern
- Opencv learning notes -day3 (mat object and creation related operations mat:: clone(), mat:: copyto(), mat:: zeros(), mat:: ones(), scalar()...)
- Differences between the notify(), notifyall(), notifydatasetchanged(), notifydatasetinvalidated() methods in the adapter
- ES6 learning road 5 symbol
- Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
- Treatment process record of Union Medical College Hospital (Dongdan hospital area)
- 桂林 穩健醫療收購桂林乳膠100%股權 填補乳膠產品線空白
- Metasploit practice - SSH brute force cracking process
- Talk about the kotlin cooperation process and the difference between job and supervisorjob
- Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
猜你喜欢
[wechat applet] realize applet pull-down refresh and pull-up loading
Summary of Android knowledge points and common interview questions
Rew acoustic test (III): generate test signal
Applet learning path 2 - event binding
Sort (simple description)
Talk about how the kotlin process started?
12. problem set: process, thread and JNI architecture
快应用中实现自定义抽屉组件
Esp32 things (II): sharpening the knife without mistaking firewood - make preparations before project development
Agp7.0|kts makes a reinforced plug-in
随机推荐
Bind threads to run on a specific CPU logical kernel
Get to know handler again
Esp32 (6): Bluetooth and WiFi functions for function development
[paid promotion] collection of frequently asked questions, FAQ of recommended list
Deep understanding of continuation principle
Differences between the notify(), notifyall(), notifydatasetchanged(), notifydatasetinvalidated() methods in the adapter
Esp32 things (VIII): music playing function of function development
Harmonyos actual combat - ten thousand words long article understanding service card development process
float
How to format an UTC date to use the Z (Zulu) zone designator in php?
Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())
Deep Learning with Pytorch- neural network
About MySQL Boolean and tinyint (1)
Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
Occasionally, Flink data is overstocked, resulting in checkpoint failure
[protobuf] protobuf generates cc/h file through proto file
Flutter theme (skin) changes
Rew acoustic test (IV): test principle of rew
Why must redis exist in distributed systems?
Interpretation of source code demand:a rotation equivariant detector for aerial object detection