+ Start a Discussion
RajitRajit 

Error : Schedulable class has jobs pending or in progress

I am trying to deploy one class which has implemented Schedulable interface.

But when I try to deploy it using ANT I am getting the following error :

"Schedulable class has jobs pending or in progress".

 

I am waiting for this to get resolved since more than 48 hrs and it doesn't seem to resolve.

What can be done in such case? How to deploy it to production? I tried to deploy by making packages but could not since the components in the package already exist in production and gives an error when I unzip the package. Please suggest what can be done in this situation.

bob_buzzardbob_buzzard
Have you got a scheduled job for that class present on your production org?  It may be that you need to delete the job to apply the page.
Nisar AhmedNisar Ahmed

Hi Bob,

 

Even I came across with the same issue. And I got the solution from here. Thanks again Bob.

AmitSahuAmitSahu

I am facing this in a sandbox while saving one class that was scheduled. But I have already deleted that schedule.

 

Also would like to mention that there is no schedules Apex only scheduled reports in this sandbox.

 

Anyone any idea ????

 

Preventing my production move...... :(

 

Regards,

 

J

Mayank_JoshiMayank_Joshi

Hi ,

 

The reason for this error is because your apex class is used under scheduler class . You need to delete your scheduler or edit your scheduler class(by commenting out batch/apex class)  so that it wont use such class which is required to delete . 

 

Regards,

Mayank Joshi 

achukachuk

Now this is just BRILLIANT!

 

So any time you change any of your global classes you just need to delete all your schedulers. Or you just duplicate the code that your scheduled classes need from the global classes (and update everything every time when business requirements change). 

 

 

bob_buzzardbob_buzzard

Not quite any time that you change a global class, but yes every time that you change a global class that is scheduled.

 

I try to develop these in managed packages if I can - that allows the classes to be upgraded while leaving the schedules in place.  Obviously it also brings its own challenges, so it isn't a silver bullet.

achukachuk

>Not quite any time that you change a global class, but yes every time that you change a global class that is scheduled

 

For example my global class has methods for sending email messages to members of some groups (among other things).

It is not scheduled. But the sceduled classes use methods from this global class to report results. 


I can not update the global class - unless I delete all schedules. I undestand why they tried to put additional "protection" in place but it failed miserably - now you have to copy-paste code from global classes into scheduled classes.

Or you have to delete all your schedules before you can make any changes to the global class

askmikemaskmikem

I had this problem just recently as well with no classes in progress or scheduled.  Stumped me for quite some time.  I ended up deleting the COMPLETED job that scheduled this task and was able to move forward.

 

Just sharing, haven't confirmed this one...

Mayank_JoshiMayank_Joshi
Thanks for Sharing Mike .
TechOwlTechOwl

askmikem : How were you able to delete the COMPLETED job?  I assume you are talking about the AsyncApexJob record where Status = 'Completed' - is this correct?  When I try to delete AsyncApexJob records via Execute Anonymous I am not able to  - any guidance will be much appreciated!

askmikemaskmikem
I deleted the jobs from the User Interface. Setup --> (Administration Setup) Monitoring - > Apex Jobs. By the way, the root cause of this problem was with Winter 13. I think this is/was a known issue although I am not certain if it has been resolved.
achukachuk

It means that you deleted your scheduled job. 

It is ok if you have one or a couple. But if you have a few - you are pretty much doing it every time one of your global classes used in the scheduled class change. Soon enough you will give up and give up using scheduled apex. 

 

EricGEricG

Did you need to change a setting somewhere to be able to delete the completed job?  I don't have an option to delete it from the UI.

 

Mayank_JoshiMayank_Joshi

Just Use System.abortJob('JOBID'); command under Developer console .

 

This will help to abort Job ,even if delete Option is not available under UI .

 

Madhura BMadhura B

I tried all the suggestions but I am still unable to edit the scheduler or the class. The error I am getting is  Error: Compile Error: Schedulable class has jobs pending or in progress at line 1 column 8 


Is there any other way to resolve this. Though salesforce says this issue is fixed http://success.salesforce.com/issues_view?id=a1p30000000STwPAAW I don't think it has yet!
 

Mayank_JoshiMayank_Joshi

If you are able to find Job ID under Apex Job section then try to delete it using below Command from Developer Console : 

 

System.abortJob('JOBID');  -- Pass JobID in quotes .Once ,it will be aborted then you can edit your scheduler class.

 

 

Rakesh YRakesh Y

I tried killing all the jobs, but still I`m not able to save the class. I don`t see any pending jobs In the Apex Jobs list, I still get this Issue. Any suggestions? It`s been almost 24 hours since I deleted all jobs.

 

Any help would be appreciated.

 

Thanks.

Rakesh.

Mayank_JoshiMayank_Joshi

Hello Rakesh ,

 

You can get in touch with Salesforce Dev support . They can help you out to Delete Apex Job /Abort . If you are still struggling to save your class .

 

Thanks,

askmikemaskmikem

Just a quick added point about deleting the Scheduled Jobs.  Do not delete the job from Apex Jobs, instead delete the job from Scheduled Jobs.

 

Good Luck.

Rakesh YRakesh Y

Thanks Mike and Mayank. I had to contact support and they killed a dangling job.

 

P.S This was not production so I just killed all the Apex Jobs.

Gauri GaikwadGauri Gaikwad

I m new to the salesforce and m trying to write the scheduler which will send the email to the employee on birthday..

But m not getting any mail due to the error "Schedulable class has jobs pending or in progress".

Thanks in advance..!

sivainkecsivainkec

KUDOS

FrankTWEFrankTWE

I am also having the issue with trying to edit an apex class and get the error:compile error: schedulable class has jobs pending or in progress at line 3 column 8. All of the jobs have been canceled or aborted and I still get the error message.

 

I have reached out to dev support and have had a case open for almost a month. I am now becoming very frustrated with the fact that nobody has been able to reach a solution. This wasn't a problem until we were updated to the latest version which is salesforce Winter 14. I was first told that this would fix the issue, it did not resolve the issue, I was then instructed to remove all scheduled jobs, I have removed all scheduled jobs and apex jobs. (This is our sandbox) This has also not resolved the issue. I have been waiting over a week for a phone call back from Dev support and have not received a single phone call when asked for an update. I am wanting to see if anyone has any other ideas or am I just stuck at the wims of Dev support?

Dev Team 34Dev Team 34
For anyone still having trouble with this, I found a solution that worked for me.

This is my Scheduler that called a class that I could not edit and save: (I did not have any pending/scheduled jobs)
 
global class LMSScheduler implements Schedulable
{
   global void execute(SchedulableContext sc) 
   {
          LMSBatch batch    = new LMSBatch(); 
        Database.executeBatch(batch,1);        
   }
}


I attempted to edit this Scheduler but even IT couldn't be edited until I discovered where and what to edit.

This is my temporarily revised Scheduler: 
 
global class LMSSchedul
{
   global void execute(string  sc) 
   {
      	//LMSBatch batch	= new LMSBatch();
		//Database.executeBatch(batch,1);		
   }
}

I removed "implements Schedulable", changed the class name, removed the "SchedulableContext" type in the execute methods parameter and replaced it with a string, and then commented out the guts of the execute method. This made it so I could save this now schedule-less Scheduler which, in turn, allowed me to edit and save the class that I previously wasn't allowed to.

So, I made my changes to the other class, saved it, and simply reverted my Scheduler back to its previous state and was able to go about my day, support-free.
 
AubryAubry
I encountered this also, and used a work-around similar to Team 34's.  When editing an Apex Class that was referenced by a Scheduler class, I simply changed the class name by 1 character, saved it, then changed the name back and saved it again.

I have no idea if there are consequences to this approach, but it worked for getting past the error.
Leo SantillanLeo Santillan
It worked for me too.Thank you Dev Team 34 !
Joris VerschoorJoris Verschoor
You can use the following code to prevent this message:
 
global class MyTaskJob implements Schedulable {
	global void execute(SchedulableContext SC) {
		System.Type objType = Type.forName('MyTask');
		Schedulable obj = (Schedulable)objType.newInstance();
		obj.execute(SC);
	}
}


global class MyTask implements Schedulable {
	global void execute(SchedulableContext SC) {
		// Do your stuff here.
	}
}

The schedule will not be statically linked to the actual implementation anymore. You will still get the error if you want to change "MyTaskJob", but there will be little to no reason to.







 
shiva chitta 9shiva chitta 9
Delete the scheduled Job with the below steps,

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.
lakshmi prasanna 84lakshmi prasanna 84
best answer here:  abort the apex jobs and then try to save the file.
for aborting the apex jobs use the following query in Work bench.
------------------------------------------------------------------------------------------------------------------------------------
List<CronTrigger> jobsToBeAborted= [select Id from CronTrigger where CronJobDetail.JobType = '7']; for (CronTrigger job : jobsToBeAborted) { System.abortJob(job.Id); }
--------------------------------------------------------------------------------------------------------------------------------------------
Rajat Kumar 54Rajat Kumar 54
Search for the Latest Government Job notifications on www.kvkalpetta.org (https://www.kvkalpetta.org/) and apply for your desired post.