'How to check which Quartz Scheduler job is not running

I have below code which i have used to check which quartz scheduler job is running. And it also send me an email the list of running scheduler job. But i dont know its not returning all the scheduler jobs which are running.And now i want to know only those scheduler job which has issues,stopped and not running. I found critical issue in my Production environment where i found that some of the scheduler jobs are not running but i really dont know which scheduler job it is.

public String getPrintJobs() {
  StringBuilder sb = new StringBuilder();
  try {
   sb.append("Quartz Jobs\r\n\r\n");

   Scheduler scheduler = this.getJobScheduler();
         // All scheduled jobs
         for (String groupName : scheduler.getJobGroupNames()) {
             for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
                 JobDetail jobDetail = scheduler.getJobDetail(jobKey);
                 final List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
     Date nextFireTime = null;
     int priority = 5;
              if (triggers.size() > 0)
              {
                  nextFireTime = triggers.get(0).getNextFireTime();
                  priority = triggers.get(0).getPriority();
              }

     sb.append("Name= "+ jobKey.getName() + " Group=" + jobKey.getGroup() + " NextFireTime=" + nextFireTime + " Priority=" + priority + " Paused=" + (isJobPaused(jobKey.getName())?"IS PAUSED":"NOT PAUSED") + " Triggers #=" + triggers.size() + "\r\n\r\n"); 
             }
         }

         sb.append("End Quartz Jobs\r\n\r\n");
  } catch (Exception e) {
   logger.debug("debugPrintJobs:" + e.getMessage());
  }

  return sb.toString();
 }

 private Boolean isJobPaused(String jobName) throws SchedulerException {
  Scheduler scheduler = this.getJobScheduler();
     JobKey jobKey = new JobKey(jobName);
     JobDetail jobDetail = scheduler.getJobDetail(jobKey);
     List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey());
     for (Trigger trigger : triggers) {
         TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
         if (TriggerState.PAUSED.equals(triggerState)) {
             return true;
         }
     }
     return false;
 }


Solution 1:[1]

I haven't used it for getting any problem but the following interfaces could be helped you.

TriggerListener could check misfired when Quartz couldn't start the job.

JobListener could check completed the job which is both successful and failure cases.

https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-07.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1