I'm facing the "ghost" job issue in an organization (thankfully is a sandbox). I had a class scheduled to run in a daily basis, and it was working fine, until I accidentally scheduled it again (2 jobs for the same class).

It ran, and scheduled itself again (the scheduling part is in the code, I didn't use SF's UI to set it up). After that I went to see the scheduled jobs, and excluded both of them.

After this whole story, I tried to edit something in the class, and Salesforce won't allow me to because supposedly the class has jobs pending or queued. When visiting the Apex Jobs page, indeed, there is a job that is marked as 'queued'. But I can't seem to delete it. When I run System.abortJob('thejobIdhere') Salesforce throws me an error:

System.StringException: You can't abort scheduled apex jobs by calling
system.abortjob with an AsyncApexJob ID. You must call system.abortjob
with the parent CronTrigger ID.

But that CronTrigger Id doesn't exist in the system anymore, so I can't delete the job.

I have seen an issue like that at Salesforce Dev Community (https://developer.salesforce.com/forums/?id=906F0000000BOuqIAG), an answer to a similar question in here (How to delete AsyncApexJob with Queued status - doesn't work for me), also there is a fixed issue (https://success.salesforce.com/issues_view?id=a1p30000000STwPAAW), but I am facing the issue.

What can I do to exclude this queued job, so I can edit my class?

  • 1
    Try running the System.abortJob using workbench and API version 32.0
    – Sreenivas
    Commented Oct 19, 2017 at 16:57

4 Answers 4


EXCEPTION: System.StringException: You can't abort scheduled apex jobs by calling system.abortjob with an AsyncApexJob ID.

You must call system.abortjob with the parent CronTrigger ID.

I tried same in workbench with lowed api version then it worked. I was able to delete 2 jobs in API version 32. Follow these steps to run this statement:

  1. login to "https://workbench.developerforce.com/login.php"
  2. On right corner, it will be showing your name and API version. Click on that link
  3. There you will find change API version, change it to 32
  4. Go to Utilities >> Apex Execute There run this command with job Id

I believe this would help you. Please let me know if you have any other questions, I would love to help you in that as well.

  • This is a bug at salesforce side and version 32 or lower work Commented Jun 18, 2017 at 14:16
  • 1
    This should be marked as correct answer ! Commented Oct 9, 2018 at 8:38
  • Developer Workbench (with API 32) worked well. I used the query SELECT Id, Status, ApexClass.Name FROM AsyncApexJob WHERE ApexClass.Name LIKE '%BatchCopy%' in my favorite tool, but the tool couldn't delete the records directly. I used DW's Apex Execute to run (in API 32!) System.abortJob('thejobIdhere'); substituting the IDs of the AsyncApexJob records one at a time. Worked great. Hopefully Salesforce will provide a better way before they retire API 32!
    – ElHombre55
    Commented Jun 16, 2022 at 20:59
  • This worked for me too!
    – jeffffc
    Commented Oct 10, 2022 at 8:42
  • Works fine! Thank you.
    – Mehedi
    Commented Jan 13, 2023 at 4:55

Turns out that I had to open a case with Salesforce to solve this. After more than 10 days, and two escalations, they didn't solve the issue. Since I didn't want to waste more time waiting for a miracle, I suggested the exclusion of the entire development environment (the sandbox) and creation of a new one.

This solved the problem, with the downside of erasing every customization I did and didn't push to the production environment. Fortunately I know how to use the Migration Tool, so I could save most of my work.


You may have to contact Salesforce support to fix this. They may be able to kill that queued job. We've had a similar issue in the past and we could only solve it by contacting SF.

  • You had to call them, or opening a case was enough? How long it took to get the issue solved? Commented Jan 4, 2016 at 14:46
  • 2
    We opened a case. I don't remember the exact timescale, but it was in the order of days, perhaps up to a week.
    – mkorman
    Commented Jan 4, 2016 at 14:47
  • 1
    You can try to edit your class in a different sandbox (if you have any) and use eclipse to migrate it. As @mkorman said, you need to contact Salesforce to delete the ghost job. Once we escalated to their research and development team to delete a job (event 1st & 2nd level support couldn't delete them).
    – SL man
    Commented Jan 4, 2016 at 18:00
  • 1
    @SLman Unfortunately we don't have another sandbox to do this test. However, I opened a case with them. They got in touch, I explained the situation (they used a GoToMetting call to record the reproduction steps, awesome!), and the guy who took my issue said they would try to escalate it to the development team. He really emphasized the "try" part, but I think it will work. I'll update this if I succeed. Thank you! :) Commented Jan 4, 2016 at 21:04
  • Just a quick update (wow after more than a week!) to this. I've opened a case with Salesforce about this, and they had me to run a batch class to see if it solved the problem (spoiler: it didn't). Now I got the case escalated to the developer support team, and I am waiting for a solution on their side. Yes. 10 days without a solution. Imagine if I had this on the production environment? I'll update this question with an appropriate answer as soon as they solve the problem. If I have to do anything else I'll answer the question. Commented Jan 14, 2016 at 19:01

You need to perform following:

List<CronTrigger> jobsToAbort = [select Id from CronTrigger where CronJobDetail.JobType = '7']; for (CronTrigger job : jobsToAbort) { System.abortJob(job.Id); }

  • Could you please add more explanation to your answer so that the answer be more clear
    – Eduard
    Commented Aug 22, 2018 at 7:10
  • Please take some time to read the entire original post. I explicitly say that I do not have the CRON job Id do use System.abortJob. Also, the problem has no other solving (as far as I could tell) other than deleting the sandbox. Commented Aug 22, 2018 at 12:12

You must log in to answer this question.

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