Print this page

'Schedulable class has jobs pending or in progress' error while saving or deploying the apex code

Knowledge Article Number 000004423

When editing an Apex class or deploying Apex code via change sets, IDE, etc., you might get the following error:

This Apex class has batch or future jobs pending or in progress

These are the scenarios in which this error is typically shown:

  1. When editing a class that implements Schedulable and that has been scheduled via the UI or via the System.schedule() method.
  2. When editing a class being called by the execute() method of the scheduled class.
  3. When editing a class being called by a class that is called in the execute() method, in other words, a dependent class.
  4. When deploying any of the above classes via change sets, IDE, etc.

In most scenarios, the error is expected and it occurs because the class is scheduled to run at a later time, and editing it or its dependencies either manually or via a deployment could result in the class having a behavior different from the one it had when it was originally scheduled. This article explains the options available to edit the affected Apex classes in these scenarios.


To troubleshoot this issue, you must first determine whether it's occurring in production or sandbox.

1. Issue is occurring in production

In production the issue can only occur when doing a deployment, if the affected scheduled class or any of its dependencies is part of the deployment. To prevent the error from occurring, you can enable "Allow deployments of components when corresponding Apex jobs are pending or in progress" under Deployment Settings. This option lets you deploy components that are referenced by Apex jobs. More information about this feature can be found here Deployment Connections and Options

2. Issue is occurring in sandbox

First, you need to determine whether the issue is occurring when editing an Apex class or when performing a deployment in that sandbox.

2.1 Issue occurs when editing Apex class

- If you know the scheduled jobs that are related to this class or its dependent classes, you can abort the jobs manually from Setup | Jobs | Scheduled Jobs.

- Because the error can occur due to dependent classes, you might need to find these in order to understand where the error is coming from, or which class is actually scheduled. To view the dependent classes, you can click on the Dependencies button in the class in question, this will only show you the classes that are called from within the current class. If you need to search for the classes that call this class, you can use the Developer Console's "Search in Files" option.

- If you are unable to locate the scheduled jobs in question, another option is to run the below anonymous Apex code in the Developer Console to abort all the scheduled jobs in the org.


  • Running this code will delete ALL scheduled jobs in the organization
  • You will need to reschedule all jobs manually after running this
  • If you are unsure of the impact of this, please contact your internal development team
  • If you wish to use ScheduleJob ID  instead of cronTrigger ID to abort the job using System.AbortJob()  use API version 32.0 or below 
List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId,
        PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey from CronTrigger 
        where State = 'Waiting' or State='Running'];
System.debug('No of jobs: '+listCronTrigger.size());

If (listCronTrigger.size() > 0)
    for (Integer i = 0; i < listCronTrigger.size(); i++)
        System.debug('Job details ::'+String.valueOf(listCronTrigger[i]));

2.2 Issue occurs during deployment

You can enable "Allow deployments of components when corresponding Apex jobs are pending or in progress" under Deployment Settings.

2.3 What to do if neither set of steps fix the issue?

If you are still receiving this error, please log a case and ask Support to follow the steps mentioned in article 000145601.

promote demote