当前位置:网站首页>Introduction to cron expression
Introduction to cron expression
2022-07-03 02:46:00 【Curious rookie】
One 、 What is? Cron 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 . Common words: timed task .
Two 、Cron The format of
Cron There are two grammatical formats as follows
Seconds Minutes Hours DayofMonth Month DayofWeek
Seconds Minutes Hours DayofMonth Month DayofWeek Year
Commonly defined “ year ” The part of can be omitted , What is commonly used in practice is The first six parts consist of
About cron The fields of are defined as follows :
| Domain | If required | Values and ranges | wildcard |
|---|---|---|---|
| second | yes | 0-59 | , - * / |
| branch | yes | 0-59 | , - * / |
| when | yes | 0-23 | , - * / |
| Japan | yes | 1-31 | , - * ? / L W |
| month | yes | 1-12 or JAN-DEC | , - * / |
| Zhou | yes | 1-7 or SUN-SAT | , - * ? / L # |
| year | no | 1970-2099 | , - * / |
Introduction to the meaning of wildcards :
“ , ” This refers to execution at more than two time points , If we were “ branch ” This field is defined as 8,12,35 , It means that they are in the 8 branch , The first 12 branch The first 35 Perform the scheduled task ;
“ - ” 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;
“ * ” All values , It can be read as “ Every time ”. If in “ Japan ” Set... In this field *, Means every day will trigger ;
“ ? ” 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's on the 8 No. 1 triggers an operation , But it doesn't matter what day of the week , We can set it like this 0 0 0 8 * ?;
“ / ” Trigger periodically on a domain , 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/10 From The first 5 Seconds to start Every time 10 Once per second , And in the “ branch ” On means from The first 5 Seconds to start Every time 10 Once per minute ;
“ 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 ”;
“ W ” 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 ”15W”, It means every month 15 The most recent working day of the . If 15 It happens to be Saturday , Find the nearest Friday (14 Number ) Trigger , If 15 It's the end of the week , Next Monday (16 Number ) Trigger . If 15 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 ”2#3” On the third Tuesday of every month .
3、 ... and 、 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 2002-2006 Express 2002-2006 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 * * ? 2005 2005 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 2002-2005 2002 - 2005 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
(23)0/2 * * * * ? each 2 second Perform tasks
(24)0 0/2 * * * ? each 2 minute Perform tasks
spring In the frame ,Cron Expressions use 5 Space is divided into 6 Domains ; Days and weeks may conflict , If you care about the day , Weekly use “?”; If you care about Zhou , Daily use “?”.
边栏推荐
- Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
- Can netstat still play like this?
- [principles of multithreading and high concurrency: 1_cpu multi-level cache model]
- SQL Server Query spécifie la structure de la table
- 基于can总线的A2L文件解析(2)
- Summary of interview project technology stack
- Javescript 0.1 + 0.2 = = 0.3 problem
- random shuffle注意
- 面试项目技术栈总结
- [C语言]给账号密码进行MD5加密
猜你喜欢
![[hcia]no.15 communication between VLANs](/img/59/a467c5920cbccb72040f39f719d701.jpg)
[hcia]no.15 communication between VLANs

Super easy to use logzero

random shuffle注意

Summary of interview project technology stack
![ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc](/img/cb/145937a27ef08050a370d5a255215a.jpg)
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
![ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc](/img/cb/145937a27ef08050a370d5a255215a.jpg)
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc

A2L file parsing based on CAN bus (2)
![Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid](/img/32/25771baad1ed06c5a592087df748f1.jpg)
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid

Principle and application of database

错误Invalid bound statement (not found): com.ruoyi.stock.mapper.StockDetailMapper.xxxx解决
随机推荐
How to implement append in tensor
GBase 8c 触发器(一)
Gbase 8C system table PG_ cast
Kubernetes family container housekeeper pod online Q & A?
Super easy to use logzero
Basic operation of binary tree (C language version)
Packing and unpacking of JS
二维格式数组格式索引下标连续问题导致 返回json 格式问题
怎么将yolov5中的PANet层改为BiFPN
The Linux server needs to install the agent software EPS (agent) database
Gbase 8C system table PG_ am
GBase 8c系统表-pg_aggregate
MUX VLAN Foundation
How to change the panet layer in yolov5 to bifpn
GBase 8c系统表pg_cast
Source code analysis | resource loading resources
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
Gbase 8C function / stored procedure parameters (I)
Global and Chinese ammonium dimolybdate market in-depth analysis and prospect risk prediction report 2022 Edition
HTB-Devel