Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Is there any way, either using apex or the API to unschedule a scheduled job?

share|improve this question
    
Are you wanting to upgrade the scheduled class or similar? There's a nice application of Type.forName you can use for decoupling classes if this is the case... –  user320 Jan 17 at 2:01
    
@user320, your comment intrigues me. Can you answer this question: salesforce.stackexchange.com/questions/24446/… ? –  Daniel Hoechst Jan 17 at 5:12
    
@DanielHoechst Peter Knolle has got ya covered –  user320 Jan 17 at 10:28

2 Answers 2

up vote 18 down vote accepted

System.abortJob(Id) can do this. Simply pass in the Id of the CronTrigger for the job in question.

You'll note the docs specifically mention System.schedule results can be passed in, which would represent the scheduled job id; this same value can be obtained from the CronTrigger table.

share|improve this answer
    
I wasn't sure if abortJob() would take a schedule, thanks for clarifying. –  greenstork Jan 17 at 16:16

You can try something like this :

List<CronTrigger> abort_job = [SELECT Id FROM CronTrigger limit 1];
    for (CronTrigger t : abort_job) { //for each record
     System.abortJob(t.Id); //abort the job
    }

http://www.interactiveties.com/blog/2012/batch-apex-test.php

share|improve this answer
1  
Ha, beat you by 30 seconds! Good answer. –  ca_peterson Jan 17 at 0:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.