• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cron expression for every 45 minutes

 
madhusudhana reddy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic