As default, quartz schedule is not shutdown after job execution. Can schedule be shutdown automatically after job execution?
Asked
Active
Viewed 192 times
1 Answers
0
Yes, Scheduler has only start method. However, you can control the repeat count, i.e how many times the scheduler should trigger.
Check the below snippet.
trigger = newTrigger()
.withIdentity("trigger3", "group1")
.startAt(myTimeToStartFiring) // if a start time is not given (if this line were omitted), "now" is implied
.withSchedule(simpleSchedule()
.withIntervalInSeconds(10)
.withRepeatCount(10)) // note that 10 repeats will give a total of 11 firings
.forJob(myJob) // identify job with handle to its JobDetail itself
.build();

Arun Bhat
- 11
- 1