File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "cron expression for every 45 minutes " Watch "cron expression for every 45 minutes " New topic

cron expression for every 45 minutes

madhusudhana reddy

Joined: Nov 10, 2009
Posts: 1
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...
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.
I agree. Here's the link:
subject: cron expression for every 45 minutes
It's not a secret anymore!