Reputation: 305
I am using Quartz library for scheduling. I have to schedule a job every 5 (could be variable) hours from a given time.
I tried using the following expression -
0 0 12/5 1/1 * ? *
I checked the output of future runs at Cronmaker.
Schedule Start Time -> Tuesday, June 21, 2017 10:30 AM
Future runs -
The expression does what it is asked but I was hoping that the 4th run would be 5 hours in addition to the 3rd run i.e something along these lines -
The 4th run goes to next day's 12:00 PM trigger. I want it to be added to the last run's time. Is there any way via which this can be achieved via the cron-expression?
Upvotes: 2
Views: 2645
Reputation: 7273
CronSchedule
is not the best suited one for what you want to do.
Use SimpleSchedule
instead:
trigger = newTrigger()
.withIdentity("yourJobName", "yourJobGroup")
.withSchedule(simpleSchedule()
.withIntervalInHours(5) // every 5 hours
.repeatForever()) // keep going in intervals of 5h
.startAt(dateOf(12, 0, 0)) // start at 12:00 PM
.build();
You can find more examples in the official documentation.
Upvotes: 2