Is there a way to abort currently running batch job in Salesforce? I tried to run the query below and all it did was remove all jobs from Scheduled Jobs section without stopping the one that is currently running in the background. Please help. I would like to do it without contacting Salesforce support

    List<CronTrigger> jobsToAbort = [select Id from CronTrigger where CronJobDetail.JobType = '7'];
for (CronTrigger job : jobsToAbort) { System.abortJob(job.Id); }

Please run a SOQL query on AsyncApexJob with Status filter. CronTrigger is used to retrive Scheduled jobs wherein AsyncApexJob returns Apex Jobs (Running, Aborted, Pending, Completed etc.)


Use Below Code:-

for ( AsyncApexJob aJob : [ Select id ,Status, ApexClass.Name 
                              from AsyncApexJob where Status!='Aborted' 
                               and Status!='Completed' ] ){


  • 1
    Very useful for killing a job running amok. Thx.
    – abhi
    Jun 28 '17 at 18:56
  • 1
    This worked great for me, I could kill some jobs by Apex class name. Thanks. May 16 '18 at 14:14
  • And what if the count returned is more then 150, is there any way to abort the list of jobs in one go preventing 150 DML exception
    – ScoRpion
    Aug 24 '20 at 14:10

Went to SetUp --> Monitoring --> Apex Jobs. There was Abort option :)

  • The navigation may have changed since this answer was written, but the page still exists here: Setup -> Monitoring -> Jobs -> Scheduled Jobs
    – dana
    Jul 17 '17 at 19:25
  • New path is : Setup > Jobs > Apex Jobs or Setup > Jobs > Scheduled Jobs May 16 '18 at 13:59

Note that if you are in Lightning the Setup path has changed from the above:

Environments > Jobs > Apex Jobs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.