Home SALESFORCEAPEX How to Stop Apex Scheduled jobs in Salesforce

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:
[JAVA]

for (CronTrigger ct : [SELECT Id FROM CronTrigger]) {
    System.abortJob(ct.Id);
}

[/JAVA]

 

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

You may also like

Leave a Comment