8

I have a legacy process that has created about 2000 scheduled jobs over 12 months. They are all appearing in the Scheduled Jobs list in the UI. However, when I query the CronTriggers object, I see all these jobs have a State = DELETED.

What's the fastest way to get rid of these jobs? I've tried using Data Loader to delete the CronTrigger records but I get an insufficient permissions error. I have a case open with Salesforce but haven't heard back yet.

I have found this Known Issues item but I don't want to manually delete all 2000 jobs. https://success.salesforce.com/issues_view?id=a1p30000000STwPAAW

thanks David

0

2 Answers 2

7

You are right this is related to a known issue, but this has been adressed on SFSE before. See this question

Ghost Schedulable Classes Blocking Deployment

According to @Ralph, a SFSE user with high reputation, he has first hand experience with this and SF support was actually able to fix for him.

Salesforce support can run a quick fix to address. Contact them and ask to run "fix for locked scheduled class" and include the deployment error message.

5

IIRC, jobs stick around until a periodic clean up process clears them away. I believe jobs older than a week get cleared out automatically. I can't find any documentation for this.

To force a scheduled job to disappear you'll want to use the System.abortJob call. Unfortunately it doesn't have a batch version and each call counts as a DML statement, so it can take a while to clear all of these out. Just run the following from the developer console until you've got no scheduled jobs left.

for(CronTrigger cron : [
  SELECT Id FROM CronTrigger WHERE State = 'DELETED'
]) {
  system.abortJob(cron.id);
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .