Short answer, by default, jobs currently running are considered to be running and not restored
... but you can set the requestRecovery property when creating a job (JobDetail) to tell Quartz to restore running tasks if aka "hard shutdown" fails.
Quoting the official documentation here at the bottom of the page:
RequestsRecovery - if the task “requests recovery” and is executed during the “hard shutdown” of the scheduler (that is, the process that it runs in the event of a failure or the machine is turned off), then it runs again when the scheduler starts again. In this case, the JobExecutionContext.isRecovering () method will return true.
So what you can do, for example:
import static org.quartz.JobBuilder.*; ... JobDetail job = newJob(MyJob.class) .withIdentity("myJob", "group1") .requestRecovery(true)
source share