function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michelle ArndtMichelle Arndt 

Too many batch jobs

We cannot run a job that sends out email updates regarding CP due to too many batch jobs running.  On 9.15.15 when an update was made to SF it started an old job and I think that is what is interfering with us being able to run this job.  How do I make it so I can start the CP emails again?  
Amit Chaudhary 8Amit Chaudhary 8
Please check below Post.  I hope that will help u
https://help.salesforce.com/apex/HTViewSolution?id=000182449
//check if there are 5 active batch jobs
//In some cases, might need to add "Status='Queued' " to the criteria
if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR Status = 'Preparing')] < 5){ 
   Database.executeBatch(batchClassInstance);
} else {
   //schedule this same schedulable class again in 30 mins
   nameOfYourSchedulableClass sc = new nameOfYourSchedulableClass();
   Datetime dt = Datetime.now() + (0.024305); // i.e. 30 mins
   String timeForScheduler = dt.format('s m H d M \'?\' yyyy');
   Id schedId = System.Schedule('MatrixRetry'+timeForScheduler,timeForScheduler,sc);
}
Please let us know if this will help you

Thanks
Amit Chaudhary