1

I am developing an application that gives the user the ability to schedule some activity. Inputs that are provided by user are

  1. Value of N
  2. Option amongst Hour/Day/Week/Month
  3. Start Date
  4. Start Time

I am unable to get the cron expressions right for each of the repeat interval type i.e. Hour/Day/Week/Month so that the trigger time is calculated from the start date.

Zefira
  • 4,329
  • 3
  • 25
  • 31
Salman A. Kagzi
  • 3,833
  • 13
  • 45
  • 64

2 Answers2

2

Quartz documentation suggests using a SimpleTrigger http://www.quartz-scheduler.org/docs/cookbook/BiDailyTrigger.html, an example for every other day:

Trigger trigger = new SimpleTrigger("trigger1", "group1");
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
// 24 hours * 60(minutes per hour) * 60(seconds per minute) * 1000(milliseconds per second)
trigger.setRepeatInterval(2L * 24L * 60L * 60L * 1000L);

Note that you will need to set the trigger start time and the misfire rule.

stjohnroe
  • 3,168
  • 1
  • 27
  • 27
0

I think is a good start of how to configure triggers:

http://www.opensymphony.com/quartz/wikidocs/CronTriggers%20Tutorial.html

orjan
  • 1,482
  • 1
  • 19
  • 35
  • I have already looked into this in detail. But i have this unique req. Let me try drafting a use case that would explain what i am trying to do. User story => I want to perform some abc every 3 hours starting from 1755 hours on 30/10/2009 so, the 1st activity on 30/10/2009 1755 2nd on 30/10/2009 2055 3rd on 30/10/2009 2355 4th on 31/10/2009 0255 and so on.... Expression: 1. 0 55 */3 * * ? * => for this trigger time is calculated from 00 hours and s0 it 1st fires at 1855 and not 1755 2. 0 55 17/3 * * ? * => for this trigger first fires on 1755, 2055 & 2355 thats it now it will fire next day. – Salman A. Kagzi Oct 30 '09 at 09:56
  • U see none of the possible expression solves my issue. I am out of ideas now. Please provide me with some pointers on this. – Salman A. Kagzi Oct 30 '09 at 09:56