my dog learned polymorphism*
The moose likes Other JSE/JEE APIs and the fly likes cron expression for every 45 minutes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "cron expression for every 45 minutes " Watch "cron expression for every 45 minutes " New topic
Author

cron expression for every 45 minutes

madhusudhana reddy
Greenhorn

Joined: Nov 10, 2009
Posts: 1
Hi,
I'm using like this my cron expression :"0 0/45 * * * ?"

The above cron expression executing every 45 minutes and it's executing on every hour like 10.10am,10.55am,11.00am,11.45....
I need to execute cron expression for every 45 minutes like 10.10am,10.55am,11.40am,12.25...
Could you please any body can help me on that.
Note:Cron expression needs to execute every 45 minutes only like 10.10am,10.55am,11.40am,12.25...
Regards,
Madhu
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

To quote from the Wikipedia article about cron:

There is also an operator which some extended versions of cron support, the slash ('/') operator (called "step"), which can be used to skip a given number of values. For example, "*/3" in the hour time field is equivalent to "0,3,6,9,12,15,18,21".

So "*" specifies 'every hour' but the "*/3" means only those hours divisible by 3. The meaning of '/' specifier, however, means "when the modulo is zero" rather than "every". For example, "*/61" in the minute will in fact be executed hourly, not every 61 minutes.


I would conclude from that quote that "*/45" in the minutes field means "at minutes divisible by 45", not "every 45 minutes".

I don't see anything in the article which says anything about "every X time units" except for that quote and one place which mentions "every 5 minutes" -- which is the same as "at minutes divisible by 5". So I conclude you can't do that with cron. Especially since your experiment tends to confirm what the Wikipedia article says.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: cron expression for every 45 minutes
 
Similar Threads
Cron expression to run every two days from the current day
creating a cron file
Cron expression for executing job every hour. + quartz scheduler
Cron expression issue
Calendar, recurring events how to store ?