当前位置:网站首页>Cron expressions in scheduled tasks
Cron expressions in scheduled tasks
2022-06-11 08:38:00 【R.Jamin Cheng】
In a scheduled task cron expression
1、cron Definition of expression
cron An expression is a string , The string consists of 6 The spaces are divided into 7 Domains , Each domain represents a time meaning . The format is as follows ( Commonly defined “ year ” The part of can be omitted , What is commonly used in practice is The first six parts consist of ):
[ second ] [ branch ] [ when ] [ Japan ] [ month ] [ Zhou ] [ year ]
2、cron Definition of each field
| Domain | If required | Values and ranges | wildcard |
|---|---|---|---|
| second (Second) | yes | 0-59 The integer of | , - * / |
| branch (Minute) | yes | 0-59 The integer of | , - * / |
| when (Hour) | yes | 0-23 The integer of | , - * / |
| Japan (Day) | yes | 1-31 The integer of | , - * ? / L W |
| month (Month) | yes | 1-12 An integer of or JAN-DEC | , - * / |
| Zhou (DayofWeek) | yes | 1-7 The integer of or SUN-SAT | , - * ? / L # |
| year (Year) | no | 1970-2099 | , - * / |
3、cron Wildcards and cases of
, This refers to execution at more than two time points . For example “ when ” This field is defined as 8,14,17, It means that they are in the 8 when , The first 14 Hour and at 17 Execute the scheduled task .
for example : 0 0 8,14,17 * * ?- This is better understood by specifying a continuous range in a domain , If we were “ when ” This field defines 1-6, It means in 1 To 6 Trigger every hour between points , use , Express 1,2,3,4,5,6
for example : 0 0 1-6 * * ?* All values , It can be read as “ Every time ”. If in “ Japan ” Set... In this field *, It means that it will trigger every day .
for example :0 0 0 * ?( Daily 0 when 0 branch 0 second )? Indicates that no value is specified . The scenario used is that you don't need to care about the current value of this field . For example, it should be done on the 28 No. 1 triggers an operation , But it doesn't matter what day of the week
for example :0 0 0 28 * ?/ On a domain periodic Trigger , The symbol divides the expression in its field into two parts , The first part is the starting value , It's going to decrease by one unit except seconds , such as stay “ second ” Defined on the 5/30 From The first 5 Seconds to start Every time 30 Execute once , And in the “ branch ” On means from The first 5 Seconds to start Every time 30 Once per minute .
for example : 5/30 * * * ?
for example :0 5/30 * * ?L In English LAST It means , Only in “ Japan ” and “ Zhou ” Use in . stay “ Japan ” Set in , Represents the last day of the month ( According to the current month , If it's February, it will be based on whether it's Runnian ), stay “ Zhou ” Last means Saturday , amount to ”7” or ”SAT”. If in ”L” Add the number before , It means the last . For example, in “ Zhou ” Set up ”7L” This format , said “ Last Saturday of the month ”. For example, every Saturday morning 7 Do it once
for example :0 0 7 ? * LW Represents the working day closest to the specified date ( Monday to Friday ) Trigger , Only in “ Japan ” Can only be used after a specific number . If in “ Japan ” Upper position ”16W”, It means every month 16 The most recent working day of the . If 16 It happens to be Saturday , Find the nearest Friday (15 Number ) Trigger , If 16 It's the end of the week , Next Monday (17 Number ) Trigger . If 16 It happens to be on weekday ( Monday to Friday ), It will trigger on that day . If it is “1W” It can only be pushed to the next most recent working day of this month, but not to the previous month .
# Indicates the day of the week of the month , It only works on “ Zhou ” On . For example, in 4#2, The second Wednesday of a month
LW: These two characters can be used together , On the last working day of a month , The last Friday .
Examples of common expressions
(1)0 0 2 1 * ? * In the month of 1 Early in the morning 2 Adjust the task
(2)0 15 10 ? * MON-FRI From Monday to Friday every morning 10:15 Perform operation
(3)0 15 10 ? 6L 2022-2026 Express 2022-2026 Last Friday morning of each month of the year 10:15 Executive work
(4)0 0 10,14,16 * * ? Every morning 10 spot , Afternoon 2 spot ,4 spot
(5)0 0/30 9-17 * * ? Every half hour during 9 to 5 working hours
(6)0 0 12 ? * WED Every Wednesday at noon 12 spot
(7)0 0 12 * * ? Every day at noon 12 Some trigger
(8)0 15 10 ? * * Every morning 10:15 Trigger
(9)0 15 10 * * ? Every morning 10:15 Trigger
(10)0 15 10 * * ? * Every morning 10:15 Trigger
(11)0 15 10 * * ? 2022 2022 Every morning in 1986 10:15 Trigger
(12)0 * 14 * * ? Every afternoon 2 Point to the afternoon 2:59 During each of the 1 Minutes to trigger
(13)0 0/5 14 * * ? Every afternoon 2 Point to the afternoon 2:55 During each of the 5 Minutes to trigger
(14)0 0/5 14,18 * * ? Every afternoon 2 Point to 2:55 During and in the afternoon 6 Point to 6:55 During each of the 5 Minutes to trigger
(15)0 0-5 14 * * ? Every afternoon 2 Point to the afternoon 2:05 During each of the 1 Minutes to trigger
(16)0 10,44 14 ? 3 WED Wednesday afternoon in March every year 2:10 and 2:44 Trigger
(17)0 15 10 ? * MON-FRI Monday to Friday morning 10:15 Trigger
(18)0 15 10 15 * ? monthly 15 The morning of 10:15 Trigger
(19)0 15 10 L * ? The morning of the last day of each month 10:15 Trigger
(20)0 15 10 ? * 6L Last Friday morning of the month 10:15 Trigger
(21)0 15 10 ? * 6L 2022-2025 2022 - 2025 Last Friday morning of every month in 2006 10:15 Trigger
(22)0 15 10 ? * 6#3 The third Friday morning of each month 10:15 Trigger
边栏推荐
- Introduction to database system experiment report answer Experiment 6: advanced query of data table
- Web design and website planning assignment 14 add background music to the video
- Web design and website planning assignment 12 online registration form
- Pg/oracle database ASCII code to string custom function
- 【node】npm部分
- 补2:圆环回原点问题
- Anaconda+tensorflow most effective summary version (blood and tears summary of 6 reloads)
- B+ super tree helps you know the underlying structure of MySQL
- [cvpr2022] intensive reading of querydet papers
- 盘它!用「飞项」轻松管理各类型项目
猜你喜欢

Multiple limit of the same field of SQL

用飞项进行目标管理,不做职场上的“无头苍蝇”

Jupyter notebook code completion plug-in + Solution

Typescript header file usage details

(一)aac开篇-核心组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧(转载)

How to make hyperlinks in RichTextBox- How can I make a hyperlink work in a RichTextBox?

Reference implementation scheme of database database and table division strategy

MySQL advanced features, you can read more about it and meet the interview

(taking pytorch as an example) a simple understanding of the regularization method of path (depth) -drop path

指定环境下安装Jupyter
随机推荐
Reference implementation scheme of database database and table division strategy
Mongodb--- automatically delete expired data using TTL index
Introduction to database system experiment report answer Experiment 6: advanced query of data table
ICML2022有意思的文章
(resolved) typeerror: meshgrid() got an unexpected keyword argument 'indexing‘
Idea annotation settings
Introduction to guava cache usage
【1】 Integrated learning: quickly understand Integrated Learning
@Usage details of postconstruct, initializingbean and initmethod
深度学习入门之pytorch安装
Cyclic sort
[cvpr2022] intensive reading of querydet papers
二、渲染 Camera 的数据
TRUNC in pytorch_ normal_ principle
In place reversal of a LinkedList
进程间的通信
Zipkin入门
Difference between threadpooltaskexecutor and ThreadPoolExecutor
torch. Var (), sample variance, parent variance
[software tools] screen recording software captura