1
votes

I was wondering if it possible to get the trigger cron expression from a Quartz Job.

I'm trying to do this for a few unit tests.

Gist from bassmartin's Answer

https://gist.github.com/jdgiotta/8c33402c1a026c2ccb12

1

1 Answers

1
votes

Yes it's possible:

Inject the JobManagerService

 def jobManagerService

Fetch the triggers of a job

List triggers = jobManagerService.quartzScheduler.getTriggersOfJob(JobKey.jobKey(MyJob.canonicalName, GrailsJobClassConstants.DEFAULT_GROUP))

Assuming your triggers are CronTrigger

triggers.each { trigger ->
   println trigger.getCronExpression()
}