In Quartz 2, this would be
Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity("someTriggerName", "someGroup")
.withSchedule(
CronScheduleBuilder.cronSchedule("0 5,15,30 * * * ?"))
.build();
This creates a trigger that activates at the right minutes past the hour. The first field is seconds; next is minutes; then hours; day of month; month; day of week (which you want to be unspecified, hence the ?
). You can specify multiple entries for each, and a *
means always; so this is all days, at 5, 10 or 15 minutes and 0 seconds past.
Now you can create a Quartz job
public class MyJob implements Job
{
public void execute(JobExecutionContext context throws JobExecutionException {
// do something useful
}
}
and schedule it using this trigger:
Scheduler sched = new StdSchedulerFactory().getScheduler();
sched.start();
sched.scheduleJob(new MyJob(), trigger);