function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ankit Singh 6Ankit Singh 6 

How to restart scheduled apex job

I have a class which implements schedulable and below class which schedules the job
public class LeadNotContactedStart{
  public void startRun() {
        leadNotContactedImplimentation dtr = new leadNotContactedImplimentation();
        String sch = '0 0 * * * ?';
        if(test.isrunningtest()){
            system.schedule('Lead not contacted Test', sch, dtr);
        }  
        else{
            system.schedule('Lead not contacted', sch, dtr);
        }
    }
}

I needed to to edit the class which implements the schedulable in order to achieve that I had to delete the existed running scheduled job. Now after editing how could I restart same job.
Best Answer chosen by Ankit Singh 6
Tejpal KumawatTejpal Kumawat
Hello Ankit,

Go to Your Name (Nearar to setup) --> Developer Console --> Debug --> Open Execute Anonymous Window

Paste this code :
LeadNotContactedStart lnc = new LeadNotContactedStart();
lnc.startRun();
Click on Execute
 

All Answers

Tejpal KumawatTejpal Kumawat
Hello Ankit,

Go to Your Name (Nearar to setup) --> Developer Console --> Debug --> Open Execute Anonymous Window

Paste this code :
LeadNotContactedStart lnc = new LeadNotContactedStart();
lnc.startRun();
Click on Execute
 
This was selected as the best answer
Ankit Singh 6Ankit Singh 6
Thanks alot Tejpal. It worked.
Mukesh Kumar 107Mukesh Kumar 107
Run a Schedule Job NOW

ScheduleSalesTargets c = new ScheduleSalesTargets();
c.execute(null);

OR

Check the Time Now, if it is, let's say 10:39 AM, in your clock, then set the minute to 41. This will schedule the job for 10:41 AM just two minutes from now. But, if you set minute value to 38, then it will schedule to next hour 11:38 AM
 
ScheduleSalesTargets c = new ScheduleSalesTargets();
String sch = '0 0 * * * ?';
System.schedule('Sales Target Job11',  '0 41 * * * ?', c);