0
global class Scheduler01 implements Schedulable {
    global void execute(SchedulableContext SC)     
    {
        //Call other class method which will perform operations as it is 
        //recommended that all processing take place in a separate class
        doScheduling();
    }
    public void doScheduling(){
       try{
            dateTime dt=System.now().addMinutes(10); //you can specify 10 mins or 15     
                                                                              //mins or any interval
            String Csec,Cmin,Chr,Cday,Cmonth,CYear;
            Csec=String.valueof(dt.second());
            Cmin=String.valueof(dt.minute());
            Chr=String.valueof(dt.hour());
            Cday=String.valueof(dt.day());
            Cmonth=String.valueof(dt.month());
            CYear=String.valueof(dt.Year());
            String SchTimer=Csec+' '+Cmin+' '+Chr+' '+Cday+' '+Cmonth+' ? '+CYear;
            system.debug('*************SchTimer:'+SchTimer);
            Scheduler02 cas = new Scheduler02();
            system.schedule('Scheduler02: Running at '+System.now().format(), SchTimer, cas);
            //we will delete completed apex scheduled jobs for which state is DELETED

            for( CronTrigger c:[Select State,Id,EndTime,CronExpression From CronTrigger where  
                                        NextFireTime= null  AND State='DELETED' Limit 100]){
                    System.abortJob(c.id);
            }
        }
        catch(exception e){
        }
   }
}
1

2 Answers 2

4

Step 1. In developer Console select debug menu and in that menu Open execute Anonymous Window

Step 2.

System.schedule('Scheduled Job 1', '0 0 * * * ?', new yourclassName());

System.schedule('Scheduled Job 2', '0 15 * * * ?', new yourclassName());

System.schedule('Scheduled Job 3', '0 30 * * * ?', new yourclassName());

System.schedule('Scheduled Job 4', '0 45 * * * ?', new yourclassName());

This scheduler for every 15 mins to execute

5
  • here not getting the result of above execution
    – salesforce
    Jul 7, 2015 at 11:23
  • what is your error?? Jul 7, 2015 at 11:25
  • Line: 1, Column: 8 expecting a semi-colon, found '0'
    – salesforce
    Jul 7, 2015 at 11:25
  • 1
    You didn't given semicolon. Jul 7, 2015 at 11:26
  • Or you could combine them in one line as '0 0/15 * ? * * *' (use an online cron expression generator)
    – Foo Bar
    Aug 14, 2023 at 19:47
-1

you can run the apex schedular job in developer console through that code. Try this.

Scheduler01  cls = new Scheduler01 ();
database.executeBatch(cls,10);
1
  • Line: 2, Column: 1 Argument must be an object that implements Database.Batchable
    – salesforce
    Jul 7, 2015 at 11:27

You must log in to answer this question.

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