Skip to content

Instantly share code, notes, and snippets.

@enreeco
Created September 29, 2014 15:02
Show Gist options
  • Save enreeco/b6fc1097098f682d30fc to your computer and use it in GitHub Desktop.
Save enreeco/b6fc1097098f682d30fc to your computer and use it in GitHub Desktop.
Apex - Are there batch jobs running with a given name?
public static Boolean isThereABatchRunningWithName(String batchClassName){
List<AsyncApexJob> jobs = [Select ApexClass.Name,JobType From AsyncApexJob
Where Status IN ('Queued','Processing','Preparing')
and ApexClass.Name = :batchClassName limit 1];
return jobs.isEmpty()==false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment