Skip to main content

Posts

Showing posts with the label how to run a class in 10min interval

How to schedule one class to run in every 1 mins?

Sometimes we need to run a class in every minute to do some operation.     // This section of code will schedule the next execution 1 minutes from now    global class Scheduling_Svc_WS_CreateBatch implements Schedulable{  // Execute method     global void execute(SchedulableContext SC) {          datetime nextScheduleTime = system.now().addMinutes(1);          string minute = string.valueof(nextScheduleTime.minute());          string second = string.valueof(nextScheduleTime.second ());          string cronvalue = second+' '+minute+' 0-23 * * ?' ;          string jobName = 'selfReschedulingClass ' +nextScheduleTime.format('hh:mm');          Scheduling_Svc_WS_CreateBatch p = new Scheduling_Svc_WS_CreateBatch();           system.schedule(jobName, cronvalu...