当前位置:网站首页>Learn about scheduled tasks in one article
Learn about scheduled tasks in one article
2022-07-19 04:56:00 【Xiaoxinai programming】
Catalog

What is a scheduled task ?
Timing task , A brief description is to trigger the execution of an action within a specified time . Similar to us tonight 12 I want to buy something , Then you need to set an alarm clock to remind you , Tell you 12 Point you need to buy something , This alarm clock reminds you regularly , It's a scheduled task .
Application scenarios for scheduled tasks
Place the order :30 Realize the payment function within minutes .
Place the order : Start a timed mission ; Whether to pay , payment , Order fulfillment ; No payment , Cancellation of order .
database : Clean up regularly , Statistics .
Use Schedule Achieve timed tasks
Cron An expression is a string , String to 5 or 6 Space between , It is divided into 6 or 7 Domains , Every time
A domain represents a meaning ,Cron There are two grammatical formats as follows :
(1) Seconds Minutes Hours DayofMonth Month DayofWeek Year
(2)Seconds Minutes Hours DayofMonth Month DayofWeek
Field | permitted | Allowed special words |
---|---|---|
second | – 0~59 The integer of | , - * / Four characters |
branch | 0~59 The integer of | , - * / Four characters |
Hours | 0~23 The integer of | , - * / Four characters |
date | 1~31 The integer of ( But you need to think about the number of days in your month ) | ,- * ? / L W C Eight characters |
month | 1~12 Or JAN-DEC | , - * / Four characters |
week | 1~7 Or SUN-SAT(1=SUN) | , - * ? / L C # Eight characters |
year ( Optional , leave a blank ) | 1970~2099 | , - * / Four characters |
Example
@Configuration
@EnableScheduling
public class MyJobTest {
@Scheduled(cron="0/2 * * * * *")
public void task(){
System.out.println(" Time :"+
LocalDateTime.now());
}
}
Use quartz Achieve timed tasks
1、 introduce jar
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starterquartz</artifactId>
</dependency>
边栏推荐
猜你喜欢
一文了解配置中心
MySQL必知必会!!!看这一篇就足够了!!!
【Lipschitz】基于matlab的Lipschitz李氏指数仿真
[FPGA tutorial case 27] realize dual port RAM ping-pong structure through Verilog
邮箱发送邮件(包含附件,网易、QQ)
浅聊全局过滤器
Conception finale: système distribué de gestion de la santé pour la prévention des épidémies hautement simultanées basé sur vue + socket + redis
Tidb performance optimization overview
CVE-2017-12635 Couchdb 垂直权限绕过漏洞复现
Mysql database table a data synchronization to table b
随机推荐
CVE-2022-23131 Zabbix SAML SSO认证绕过漏洞
tidb 学习
JS中substr与substring的区别
DSL search results processing, including sorting, paging, highlighting
Expected to replace deepfake? Uncover this year's super popular nerf Technology
POC——DVWA‘s File Inclusion
Database and the future of open source
MySQL必知必会!!!看这一篇就足够了!!!
Redis 集群面试题
shardingproxy分库分表实战及同类产品对比
Hightec new aurix tc37x demo project
OLTP 负载性能优化实践
数据库与开源的未来
简洁UI好玩的文字转换emoji表情微信小程序支持句子词语转换_源码
3.RestClient查询文档
Tidb performance optimization overview
高等数学笔记:关于等价无穷小替换的一个猜想
Blessing for the elderly popular short video wechat applet source code download support traffic master
Codeforces Round #419 (Div. 1)B - Karen and Test
Overview of CKA core knowledge points