How to Stop Apex Scheduled jobs in Salesforce

System.abortJob(Id) can do this. Simply pass in the Id of the AsyncApexJob for the job in question.

You’ll note the docs specifically mention System.schedule results can be passed in, which would represent the scheduled job id; this same value can be obtained from the AsyncApexJob table.

Its possible using the below piece of code:
Run the following piece of code in your salesforce org developer console to deactivate any active jobs
-> Go to developer console> Debug (from top menu)> Open Execute Anonymous Window.

Paste below code and hit Execute from Developer Console:


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

System.AbortJob(aJob.Id);

}

 

Job Status from Apex Job Queue Object:

STATUS DESCRIPTION
Queued Job is awaiting execution.
Preparing The start method of the job has been invoked. This status might last a few minutes depending on the size of the batch of records.
Processing Job is being processed.
Aborted Job was aborted by a user.
Completed Job completed with or without failures.
Failed Job experienced a system failure.

Monitoring the Apex Job Queue – https://dreamevent.secure.force.com/articleView?id=code_apex_job.htm&type=0

(728)

Written by 

I am Sakthivel Madesh, a certified Salesforce Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 13x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply