0

Right now we are running java cron jobs on Linux environment. and start/stop of job is doing by Linux commands on putty. which will daily schedule automatically.but my requirement is i want to control those cron jobs from UI(like spring web application). like starting a job, stopping a job, current running status of job. is there any libraries are available? Please suggest. thank you.

  • I have answered for almost same requirement look in that < http://stackoverflow.com/questions/20546403/spring-scheduler-change-cron-expression-dynamically/40692784#40692784 > – Prafful Nagpal Nov 19 '16 at 18:09
  • I have answered for similar requirement < http://stackoverflow.com/questions/20546403/spring-scheduler-change-cron-expression-dynamically/40692784#40692784 > look in this – Prafful Nagpal Nov 19 '16 at 18:11
  • http://stackoverflow.com/questions/20546403/spring-scheduler-change-cron-expression-dynamically/40692784#40692784 I have already answered for same requirement – Prafful Nagpal Nov 19 '16 at 18:14

2 Answers2

0

Yes, there is check out: http://www.quartz-scheduler.org/

It has 3 or 4 SQL tables that you configure and then you can list all jobs, their state, when they'll run next time, etc.

Just as quick look example:

 List<HashMap<String,Object>> jobs = new ArrayList<>();
 Scheduler sch = MyScheduler.getScheduler();
       for (String groupName : sch.getJobGroupNames()) {
        for (JobKey jobKey : sch.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
             String jobName = jobKey.getName();
             String jobGroup = jobKey.getGroup();
             List<Trigger> triggers = (List<Trigger>) sch.getTriggersOfJob(jobKey);
             Trigger tg = triggers.get(0);
             Date nextFireTime = tg.getNextFireTime();

             System.out.println("[jobName] : " + jobName + " [groupName] : " + jobGroup + " - " + nextFireTime);

            HashMap<String,Object> jb = new HashMap<>();
             jb.put("triggerKey", tg.getKey());
             jb.put("triggerGroup", tg.getKey().getGroup());
             jb.put("triggerName", tg.getKey().getName());
             jb.put("nextFireTime", nextFireTime);
             jb.put("trigger_state", sch.getTriggerState(triggers.get(0).getKey()));
             jobs.add(jb);
        }
     }
0

You may want to check our QuartzDesk Executor (QE) free and open-source app on GitHub. QE is a spring-based Java webapp built on top of the popular Quartz scheduler API and out-of-the-box it allows you to schedule execution of the following types of tasks/jobs:

  • Local executable applications and scripts (e.g. *.sh, *.exe, *.cmd, *bat).
  • Remote executable applications and scripts (through SSH).
  • Externalized Java Quartz jobs.
  • JDBC queries.
  • HTTP(S) POST requests.

Since the QE is open-source you can extend it and add your own custom types of jobs.

QE is mean to be used with our QuartzDesk job management and monitoring platform that provides additional features and a decent GUI. If you decide to give the QuartzDesk platform a try, you will get persistent execution history, visual job execution statistics, job execution notifications (email, instant messages, SNMP Trap, web-service invocation), job chaining etc.

QuartzDesk can intercept log messages produced by executed jobs. These log messages are visible for all currently executing jobs so that you can see what your jobs are currently doing at runtime (!). In the execution history view you can see log messages of all finished jobs executions. For OS-native jobs (shell scripts, executable commands etc.), QuartzDesk can intercept messages produced by these jobs on their standard and error output.

This is what the QuartzDesk GUI, that is connected to a QE instance, looks like:

QE instance in the QuartzDesk GUI

Jan Moravec
  • 1,808
  • 1
  • 15
  • 18