I am trying to schedule a batch after 15 mins from my post installation script which take 100 records and process it. But it might be possible that when my scheduled job will start already another 5 jobs are running or in queue in that case i want to reschedule my batch for next 15 mins.
I am not sure where to put this check which will count no of running apex jobs.
My post installation script contain below code.
String batchqueryString = 'Select ID, Account__c,InstanceList__c from CustomerInfo__c'; BatchHandler bhObj = new BatchHandler(); bhObj.queryStr = batchqueryString; bhObj.batchMethodName = 'abc'; system.scheduleBatch(bhObj,'Scheduleabc',15,100);
Should i write logic to check counts of apex jobs running in BatchHandler execute function and if jobs running are less than 5 then proceed other wise create a new scheduler with same name for next 15 min.