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
niharnihar 

how to schedule batch class for every 2 minuets

Hi all, 
how to schedule batch class for every 2 minuets 
for every 2minutes the batch class should run.......

Thanks in advance...........
Best Answer chosen by nihar
Ajay K DubediAjay K Dubedi
Hi Nihar,

Here is code, hope this will help you:
 
//Scheduler Class that calls your batch class

global class SchedulerClass implements Schedulable  
{
    global void execute(SchedulableContext SC)
    {

     BatchClass obj = new BatchClass();
     Database.executeBatch(obj);
     
    }
}

//Execute following code in Execute Anonymous

SchedulerClass obj = new SchedulerClass();
String str;
for(integer i=0;i<30;i++){
str= '0 '+i*2+'   ?  *'; 
System.Schedule('Job name'+i,str,obj);
}
If this will help you mark this as best Answer.

Thanks,
Ajay Dubedi.