Meaningless Drivel is fun!*
The moose likes Linux / UNIX and the fly likes Cron expression to run every two days from the current day Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Cron expression to run every two days from the current day" Watch "Cron expression to run every two days from the current day" New topic
Author

Cron expression to run every two days from the current day

sivachithambaram Rangaraj
Greenhorn

Joined: Feb 10, 2010
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
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    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".

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

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
sivachithambaram Rangaraj
Greenhorn

Joined: Feb 10, 2010
Posts: 5
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

Joined: Feb 10, 2010
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

Also, any moderator watching this thread, please move it to "Other JSE/JEE API" section.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30919
    
158

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cron expression to run every two days from the current day