enter code hereCurrently I have a batch which I'm scheduling after 2-2 minutes but because it has the same job name it doesn't allow to reschedule. Is there any way to reschedule the same batch. Because when i go to All schedule job in UI I can see it listed with no next schedule run. Now If i give different name it will run but with all the schedule batch listed in All schedule job . Please suggest me how to reschedule the same batch by apex.
String day = string.valueOf(system.now().day());
String month = string.valueOf(system.now().month());
String year = string.valueOf(system.now().year());
String minute = string.valueOf(system.now().minute() + 2);
String hour = string.valueOf(system.now().hour());
String nextFireTime = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
BatchSample b = new BatchSample();
CronTrigger[] jobList = [SELECT Id, CronJobDetail.Id, CronJobDetail.Name, CronJobDetail.JobType,NextFireTime
FROM CronTrigger Where CronJobDetail.Name Like 'BatchSample' AND NextFireTime > :System.now()];
if(jobList.size()==0)
System.schedule('BatchSample', nextFireTime, b);
System.scheduleBatch()
with theminutesFromNow
parameter? – David Reed♦ Aug 21 '18 at 20:12