Find your content:

Search form

You are here

Scheduling Batch class

 
Share
  How to schedule the batch for every two hours per day? 
  I try like this 

   String schedule = '0 0 1/2 * * ?';
   System.schedule('Jobname',schedule,new SampleTracking());

but i don't know it is corrrect or not.I execute it in developer console it shows the start time as after 2hours from the current time.

Thanks

Venkatsforce


Attribution to: Venkatsforce

Possible Suggestion/Solution #1

You can do that with the following cron string.

apexScheduledJob myJob = new apexScheduledJob ();
String sch = '0 0 0,2,4,6,8,10,12,14,16,18,20,22 ? * *';
System.schedule('My Job', sch, myJob);

This job will run every 2 hours, at the top of the hour, starting at midnight.


Attribution to: Chris Duncombe
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34672

My Block Status

My Block Content