1

I am writing a kind of start - pause - resume - pause - resume -(at regular intervals) kind of job in Quartz. I am using a SimpleTrigger for initial experimentation.

I would like to how I can find the time a job has been running. I looked at the Scheduler class and there were no methods directly to find it.

Could some one suggest me a way of finding how long a job has been running?

Thanks, Abi

Abhishek
  • 6,862
  • 22
  • 62
  • 79

1 Answers1

0

Call scheduler.getCurrentlyExecutingJobs() to get the set of job's currently executing (or more precisely to get the JobExecutionContext of each).

Then you can call getFireTime() on the JobExecutionContext to see what time the execution started.

jhouse
  • 2,674
  • 1
  • 18
  • 17
  • Assuming if a job is executing at every interval of 10 minutes and its started at 09:00 .While I fetch the getFireTime() around 09:35 what does it return? 09:00 or 09:30? – Abhishek Feb 11 '11 at 04:29
  • 9:30. If it's a SimpleTrigger, it's startTime will be 9:00 - but that trick won't necessarily work for other trigger types. – jhouse Feb 11 '11 at 15:21
  • To clarify, it won't necessarily work for other trigger types, because a SimpleTrigger fires its first time on the startTime, but that isn't necessarily true of other trigger types, for example, A CronTrigger could be set to fire every 10 minutes during the hour of 9:00 every day, e.g. "0 0/10 9 * * ?" but it's start time could be set to virtually anything before or on the time the want it to start firing - unless you purposely have your app always set the CronTrigger's startTime to the first fire time. – jhouse Feb 11 '11 at 15:43