+ Start a Discussion
West415West415 

Mass Delete Scheduled Jobs?

Hi,
 

I have about 800+ scheduled jobs in my org and I want to mass delete them.  How can I do this either through the UI ideally in bulk or via code?  Any help appreciated.  I know I can click the delete link next to each job, but I don't want to do that because it will takes a LONG time obviously.

Thanks!

Best Answer chosen by West415
KaranrajKaranraj
Go to Execute Anonymous window in developer console and execute the following code, which will abort the scheduled jobs in your org
 
for(CronTrigger delCron: [SELECT Id FROM CronTrigger ])  {
    System.abortJob(delCron.Id);
}
The above will delete all the scheduled jobs in your org, I strongly recommend you to test in sandbox for few jobs and then try in the production instances, you can also filter with the fields in the query. Check here for corn trigger fields (http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_crontrigger.htm)
 

All Answers

KaranrajKaranraj
Go to Execute Anonymous window in developer console and execute the following code, which will abort the scheduled jobs in your org
 
for(CronTrigger delCron: [SELECT Id FROM CronTrigger ])  {
    System.abortJob(delCron.Id);
}
The above will delete all the scheduled jobs in your org, I strongly recommend you to test in sandbox for few jobs and then try in the production instances, you can also filter with the fields in the query. Check here for corn trigger fields (http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_crontrigger.htm)
 
This was selected as the best answer
West415West415
And to confirm, this will remove them from the UI as well or just abort them?
KaranrajKaranraj
It will delete job and remove them from the UI
Nick SanchezNick Sanchez
Is there a way to delete just 1 scheduled apex batch job? 
Nicole LevyNicole Levy

Nick,

Considering the above code, the way to do that would be to call 

System.abortJob(IDOFJOB);
 

where "IDOFJOB" is the salesforce id of that shceduled batch job.