quartz获取缓存中所有运行中的Job

原文地址:https://blog.csdn.net/zzm8421/article/details/77769203

Quartz 2.1.5:

public static void getAllJobs(){
try {
Scheduler scheduler = schedulerFactory.getScheduler();
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
String jobName = jobKey.getName();
String jobGroup = jobKey.getGroup();
//get job's trigger
List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
Date nextFireTime = triggers.get().getNextFireTime();
System.out.println("[jobName] : " + jobName + " [groupName] : "
+ jobGroup + " - " + nextFireTime);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

Quartz 1.8.6

Scheduler scheduler = new StdSchedulerFactory().getScheduler();

//loop all group
for (String groupName : scheduler.getJobGroupNames()) { //loop all jobs by groupname
for (String jobName : scheduler.getJobNames(groupName)) { //get job's trigger
Trigger[] triggers = scheduler.getTriggersOfJob(jobName,groupName);
Date nextFireTime = triggers[].getNextFireTime(); System.out.println("[jobName] : " + jobName + " [groupName] : "
+ groupName + " - " + nextFireTime); } }
上一篇:install ubuntu


下一篇:Android学习之基础知识四-Activity活动7讲(活动的启动模式)