[英]Scheduled task to run every 3 days at given time
I am using Quartz 2 scheduler for scheduling tasks. 我正在使用Quartz 2 Scheduler来计划任务。 Below is what I need.
以下是我需要的。
Below is how I coded it. 以下是我的编码方式。 It will execute (with its scheduler of course) once the user click on a button in web app)
一旦用户单击Web应用程序中的按钮,它将执行(当然还有其调度程序)
Trigger passportTrigger1 = newTrigger()
.withIdentity(passportTriggerKey1)
.withSchedule(simpleSchedule().withIntervalInHours(3*24).repeatForever())
.startAt(todayAt(8,0,0)).build();
However you can see that I have used startAt(todayAt(8,0,0))
. 但是您可以看到我已经使用过
startAt(todayAt(8,0,0))
。 What happens if the user turned on the scheduler after 8.00 AM today? 如果用户今天凌晨8:00打开调度程序,会发生什么情况? The job will be scheduled immediately or it will never get scheduled?
该作业将立即安排,还是永远不会安排?
您还可以检查当前时间:如果是在上午8点之前startAt(todayAt(8, 0, 0)
startAt(tomorrowAt(8, 0, 0))
startAt(todayAt(8, 0, 0)
否则startAt(tomorrowAt(8, 0, 0))
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.