Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Can quartz cron expression express the Fortnightly, Quarterly and Half yearly?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

fortnightly, quarterly and half yearly.


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)
 
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't putting "3/3" and "6/6" in the month field achieve quarterly and semiannually?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"3/3" and "6/6"


I overlooked that one, thank you Paul.
 
Vichy Yao
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I think I didn't make myself clear enough.

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 ]
 
I like tacos! And this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic