Java

定时任务cron

2022-09-01  本文已影响0人  代码的路

原文链接

格式

{秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}

用法

实例

@RestController
@EnableScheduling
public class MyController {    
    @Scheduled(cron = "1/10 * * * * ? ")  //10s一次    
    public void learn(){        
        System.out.println("hello world");    
    }
}

在线生成

在线生成 cron 语句的网站:

https://www.bejson.com/othertools/cron/

 
 

学习更多编程知识,请关注我的公众号:

代码的路

上一篇 下一篇

猜你喜欢

热点阅读