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
• Bear Bibeault
• Jeanne Boyarsky
• Tim Cooke
Sheriffs:
• Knute Snortum
• Junilu Lacar
• Devaka Cooray
Saloon Keepers:
• Ganesh Patekar
• Tim Moores
• Carey Brown
• Stephan van Hulst
• salvin francis
Bartenders:
• Ron McLeod
• Frits Walraven
• Pete Letkeman

# Cron expression to run every two days from the current day

Greenhorn
Posts: 5
Hi,

How to write a cron expression to execute on every two days from the current day.

I have used one expression like "1 0 18 */2 * ?" but it is firing only in the odd days.. i guess becaz it is starting it from day 1 of the month.

So can anyone help on this?

Thanks
Siva

Ranch Hand
Posts: 2908
1

sivachithambaram Rangaraj wrote:
I have used one expression like "1 0 18 */2 * ?" but it is firing only in the odd days.. i guess becaz it is starting it from day 1 of the month.

You mean the cron expression firing correctly after each 2 days, in your case, starting from 1, :
1 3 5 so on...
Thats what you want, right OR you want even/odd days execution ??
For latter case, try using "2/2" - "fire every 2 days starting on the second day of the month".

http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html

sivachithambaram Rangaraj
Greenhorn
Posts: 5

My scenario is like if i schedule it on 10th of feb the job should be executed for every n days starting on 10th feb ..not on the even days alone or not on the odd days alone...the intereval may vary from 1 to n...

sivachithambaram Rangaraj
Greenhorn
Posts: 5
I solved it by building a simple trigger with the specified interval multiplied by 24..

i.e Trigger t=Triggerutils.makeHourlyTrigger(interval*24);'
This will trigger for every n days ..

Thanks
Siva

Sagar Rohankar
Ranch Hand
Posts: 2908
1

sivachithambaram Rangaraj wrote:Thanks rohan ,for the reply..

sivachithambaram Rangaraj wrote:My scenario is like if i schedule it on 10th of feb the job should be executed for every n days starting on 10th feb ..not on the even days alone or not on the odd days alone...the intereval may vary from 1 to n...

Then I think, your expression should work.

I solved it by building a simple trigger with the specified interval multiplied by 24..

Are you sure, multiplying it by 24 hours solves your original requirement, i'e firing after each 2 days

Sagar Rohankar
Ranch Hand
Posts: 2908
1
Also, any moderator watching this thread, please move it to "Other JSE/JEE API" section.

author & internet detective
Marshal
Posts: 38664
677

Sagar Rohankar wrote:Also, any moderator watching this thread, please move it to "Other JSE/JEE API" section.

Why? It sounds like it is about cron which is a UNIX tool.

Sagar Rohankar
Ranch Hand
Posts: 2908
1

Jeanne Boyarsky wrote:

Sagar Rohankar wrote:Also, any moderator watching this thread, please move it to "Other JSE/JEE API" section.

Why? It sounds like it is about cron which is a UNIX tool.

This is what the OP wrote:

sivachithambaram Rangaraj wrote:
i.e Trigger t=Triggerutils.makeHourlyTrigger(interval*24);'

and TriggerUtils is the Quartz class.