如何安排应用程序执行

huangapple go评论64阅读模式
英文:

How can I scheduled an application execution

问题

我知道下面的注解将会在每天中午运行我的代码:

@Scheduled(cron = "0 0 12")

我应该如何修改以使得我的代码每天运行三次,分别是:

第一次在早上 08:00

第二次在中午 12:00

第三次在下午 18:00

英文:

I know that the annotation below will run my code everyday at noon:

@Scheduled(cron = "0 0 12")

How can I do to make my code run everyday, three times a day, like:

first time at 08:00 am

second time at 12:00 am

third time at 18:00 pm

?

答案1

得分: 1

这个定时任务将在8点、12点和18点运行
0 8,12,18 * * *

使用类似 https://bradymholt.github.io/cron-expression-descriptor/ 的工具来查找你的定时任务表达式。

英文:

This cron will run at 8, 12 and 18 o'clock
0 8,12,18 * * *

Use tools like https://bradymholt.github.io/cron-expression-descriptor/ to find your cron expression

huangapple
  • 本文由 发表于 2020年8月26日 02:51:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/63585358.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定