I implemented a batch job system by using Quartz 1.4.2 (a quite old version). But my clients want to schedule some batch jobs run fortnightly, quarterly and half yearly. I could not worked them out. Pleas help and thank you!
I think that you'll have to specify dates. For example, half yearly : - January, 1st : "0 0 0 1 1 ?" - June, 1st : "0 0 0 1 6 ?"
Fornightly is going to be difficult, unless you can tell which day of the week you want to use. For example : - First monday of every month : "0 0 0 ? * 2#1" - Third monday of every month : "0 0 0 ? * 2#3" - Fifth monday of every month : "0 0 0 ? * 2#5" (if any, otherwise does nothing)
Yes, of course user need to give the day of the week for fortnightly, and day of the month and month for quarterly and half yearly.
For quarterly and half yearly, now my solution is to calculate the month list in Java program fist. For example, if user want a quarterly job run on 1700, 5th of Apr, then I will generate the month list as 4,7,10,1, and then the cron expression will be something like 0 0 17 5 4,7,10,1 ? *.
Hi Christophe, I think your expression not good enough. User want the job run every two weeks exactly. So if user want the job start on 1st of Jan 08, it's a Tuesday, then actually it should run as follows:
First Tuesday of Jan 2008 Third Tuesday of Jan 2008 Fifth Tueday of Jan 2008 Second Tuesday of Feb 2008 Forth Tuesday of Feb 2008
As you can see, we cannot fix it to first, third and fifth of a month. It's changing as time goes.
Hi Paul, I ever tried 3/3 or 6/6 form and it's not really correct. 4/3 actually means start from Apr of each year, and the increment is 3. So it will miss Jan. Not only month, other fields are also same. For example 20/1 means run the job every day of every month ONLY 20th onwards. [ March 20, 2008: Message edited by: vichy baby ]