I am using Quartz 2 scheduler for scheduling tasks. 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)
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))
. What happens if the user turned on the scheduler after 8.00 AM today? 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))
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.