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
Antony RenaldAntony Renald 

How to stop background jobs?

We need to stop Job named "Duplicate Error Log Sweeper" in background jobs, any suggestions will be much appreciated.
surasura
it seems you have to contact Salesforce to abort background jobs https://help.salesforce.com/HTViewHelpDoc?id=monitoring_background_jobs.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=monitoring_background_jobs.htm&language=en_US)
Antony RenaldAntony Renald
@sura Thank you for the note.

I tried contacting them and was informed that developer support is available only for premier and partner customers.

Anyother way to stop this?
Ravi Kumar 259Ravi Kumar 259

ScheduleApex class:-
------------------------------
to stop execute of a job that was schedule use the System.abortJob() method with ID returned by the getTriggerID method

System.abortJob(sc.getTriggerID());

BatchApex class:-
---------------------------
To monitor or stop the execution of the batch Apex job, go to Setup --> Monitoring --> Apex Jobs. For more information, see “Monitoring the Apex Job Queue” in the Salesforce online help.
surasura
Salesforce internal object CronTrigger represent currently running jobs. you can query it and call system.abort() by passing it's id
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_crontrigger.htm

eg:
List<CronTrigger> job = [Select CronJobDetailId,StartTime From CronTrigger ];
system.abort(job[0].Id);

you need to add some criteria to distinguish the job you want to abort , such as ownerid or starttime
Antony RenaldAntony Renald
I tried your steps and still couldn't stop the jobs, since its runs as background jobs and not as apex jobs.  Also if someone could clarify what this Duplicate error log sweeper means it would be helpful
Antony RenaldAntony Renald
Any thoughts on this issue?
Hitesh NarulaHitesh Narula
// loop through jobs located by name that we need to abort
for(CronTrigger ct : [SELECT Id, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger WHERE CronJobDetail.Name like 'Work Order%']){

  // abort the job, try/catch because the job might not exist
    try{
        system.abortJob(ct.id);
    } catch (exception e) {}
}
Tristan LBTristan LB
Yes, there hasn't been an answer for a very long time.

but I found this for the next users who want to stop an interrupted flow interview:
there's a setup called:
"Paused Flow Interview" in Process Automation

that's all, you should have known, because it's not written anywhere.