Hi,
I'm trying to schedule a cronjob via Java code. Our case is that when I can't st scheduled cronjob that I should postpone it for 30 minutes. I thought the following code should work, but it doesn't and I can't find any documentation about it.
Does someone of you have an idea to create a trigger that will only run once on a specific time?
public void createTrigger(final CronJobModel cronJobModel) {
long t= new Date().getTime();
Date afterAddingThirtyMins=new Date(t + (1800000));
final TriggerModel triggerModel = modelService.create(TriggerModel.class);
triggerModel.setActive(Boolean.TRUE);
triggerModel.setActivationTime(afterAddingThirtyMins);
triggerModel.setRelative(true);
triggerModel.setCronJob(cronJobModel);
modelService.save(triggerModel);
}
I thought the code above should work, but the interval is now scheduled as daily while it should only run once.

Available method in TriggerModel:
setActivationTime(final Date value)
setActive(final Boolean value)
setCronExpression(final String value)
setCronJob(final CronJobModel value)
setDateRange(final StandardDateRange value)
setDay(final Integer value)
setDaysOfWeek(final List value)
setHour(final Integer value)
setJob(final JobModel value)
setMaxAcceptableDelay(final Integer value)
setMinute(final Integer value)
setMonth(final Integer value)
setRelative(final Boolean value)
setSecond(final Integer value)
setWeekInterval(final Integer value)
setYear(final Integer value)
Request clarification before answering.
I think the question is a bit confusing. For making a cron job run only once we have something called "singleExecutable" it will make the job run only once.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.