Click here to Skip to main content
15,909,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
s there any way to set end time for a cron trigger. Is it possible to edit one cron job executing. for eg: I want to set start time, trigger interval and end time in a cron job, and it may want to change change trigger interval or end time after scheduler start it.
Posted

I haven't tried this myself but the way I would do it is to create a second cron job that kills the first one.
 
Share this answer
 
Hi,

If you are referring to Cron Job in Quartz Schedular, then here[^] good tutorial.

Regards,
 
Share this answer
 
sample code to set start time

ct = new CronTrigger("cronTrigger", "group", cronExpression);

Calendar futureDate = Calendar.getInstance();
futureDate.set(Calendar.YEAR, 2013);
futureDate.set(Calendar.MONTH, GregorianCalendar.MARCH);
futureDate.set(Calendar.DAY_OF_MONTH,
futureDate.set(Calendar.HOUR_OF_DAY, 13);
futureDate.set(Calendar.MINUTE, 15);
futureDate.set(Calendar.SECOND, 10);
futureDate.set(Calendar.MILLISECOND, 0);
ct.setStartTime(futureDate.getTime());

and for end time:

Calendar ffutureDate = Calendar.getInstance();
ffutureDate.set(Calendar.YEAR, 20143);
ffutureDate.set(Calendar.MONTH, GregorianCalendar.MARCH);
ffutureDate.set(Calendar.DAY_OF_MONTH, 18);
ffutureDate.set(Calendar.HOUR_OF_DAY, 9);
ffutureDate.set(Calendar.MINUTE, 58);
ffutureDate.set(Calendar.SECOND, 15);
ffutureDate.set(Calendar.MILLISECOND, 0);
ct.setEndTime(ffutureDate.getTime());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900