• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Cron expression to run every two days from the current day

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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".

For more info:
http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html
 
sivachithambaram Rangaraj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks rohan ,for the reply..

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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


Please go though my signature.

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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, any moderator watching this thread, please move it to "Other JSE/JEE API" section.
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Hey cool! They got a blimp! But I have a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic