[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Firing trigger on a specific time and interval  XML
Forum Index -> Quartz
Author Message
jpriyank

neo

Joined: 07/18/2014 05:49:06
Messages: 5
Offline

Requirement: Create a job that triggers at specific date+time with some specific interval.

I am creating a job and trigger with SimpleSchedular,
I have given trigger start date some specific time (let's say 08/13/2014 00:00:00 HRS) and given interval withIntervalInHours let's say (24 HRS).

Problem: Job triggered on let's say 13:August: 00:00:00 HRS and completed execution on 13:August: 00:05:23, now on next day (i have given interval 24 HRS) my job started its execution on 14:August 00:05:23 HRS instead of starting at 14:August 00:00:00 HRS.

I want to configure my trigger such that it should start from 00:00:00 HRS on each repeat interval.

I am pasting my code snippet for TriggerBuider here

Trigger trigger = TriggerBuilder.newTrigger().withIdentity("Trigger-1","Trigger-1").startAt(alertDate).withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMinutes(intervalInMinutes) .repeatForever().withMisfireHandlingInstructionNowWithExistingCount()).build();


Help me out here javascript:emoticon('');
hasnaa

neo

Joined: 08/05/2014 02:45:34
Messages: 4
Offline

Did you tried using


Trigger trigger = newTrigger()
.withIdentity("Trigger-1","Trigger-1")
.withSchedule(dailyAtHourAndMinute(00, 00)) // execute job daily at 00:00
.build();
jpriyank

neo

Joined: 07/18/2014 05:49:06
Messages: 5
Offline

Thanks @hasana i tried it but i may not have to run it daily... so i want to run it on configurable interval lets say some job at 2 days interval some 3 or 1 days interval.

I am not achieving it by that.
hasnaa

neo

Joined: 08/05/2014 02:45:34
Messages: 4
Offline

well it actually count 24h from the end of the last job !

You can use in that case cronScheduleBuilder

CronScheduleBuilder.cronSchedule("0 0 0 * * ?")
jpriyank

neo

Joined: 07/18/2014 05:49:06
Messages: 5
Offline

@hasana but how i can give the time interval let's say if i have run that job on every 3 day's interval!!!
hasnaa

neo

Joined: 08/05/2014 02:45:34
Messages: 4
Offline

You can put in your crontrigger 0 0 0 1/3 *? : this one is going to fire every thre days starting on the first day of the month;

If that doesnt respond to your need you can also try with the simpletrigger using .withIntervalInDays(3) but i didn't tested it.
jpriyank

neo

Joined: 07/18/2014 05:49:06
Messages: 5
Offline

I have used the simple triggers .withIntervalInDays(3) APIs but its updating the next fire time in DB the when its completing the execution.

let's say i have given the start time 00:00:00 on some day now let's assume it is taking 5 minutes to execute the job, so what simpleScheduar does it updates next fire time as 00:05:00 HRS of next trigger date. I want all repetable jobs should start from 00:00:00 HRS


@hasana i will try with cron schedular
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team