I have a cron trigger that is scheduled to run once every month. This works fine but when I change the schedule to run every x months, let's say, every 3 months, it will not be followed. Regardless of the start date, it will always run on March, June, Sept, and Dec of every year. Here's my cron expression:
0 30 10 20 */3 ? *
I recently came across with the documentation of Quartz's cron expression and was enlightened by the explanation on the "/" character.
The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7",
it does NOT mean every 6th month, please note that subtlety.
Now I'm wondering if it's possible to schedule a cron trigger that runs every x months and what will be the correct cron expression for this.
Badly need your help guys.. Thanks!
TriggerUtils class has many convenience methods (to avoid figuring out cron expressions!) like makeHourlyTrigger, makeMonthlyTrigger etc.
This is pseudo code, just to give you an idea:
You can put additional logic in your jobDetail class to do-whatever-you-want or not-do, to achieve for example doing-your-task only on even months etc.
I have used these APIs in the past to set triggers instead of CronTrigger class.
Joined: Sep 23, 2009
Ok thanks. My monthly cron trigger schedule (fires every month) is working fine so I'm still checking if I can continue using CronTrigger as my trigger and just change something in JobDetail like you said.
Joined: Sep 23, 2009
Hi.. Can you elaborate further on how this can be done in JobDetail?
Joined: Apr 27, 2003
joei salijado wrote:Hi.. Can you elaborate further on how this can be done in JobDetail?
Well some custom logic...
If you store when actual 'Job' ran succesfully last time; you can always refer that information to decide whether it should run 'this' time or not etc.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Quartz Scheduler that runs every x months