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
raji ch 8raji ch 8 

we have to run a batch job and from that batch job 1 we have to run another batch job 2 must be delayed by 10 mins when batch 1 run?

Sabal Jain 9Sabal Jain 9
Starting a batch job from a batch job is fairly straightforward. The key is placement of the code that actually starts the new batch. The code that starts the new batch needs to be placed in the finish method of the initial batch.
example:

global void finish(Database.BatchableContext BC)
{
//Add your start code for the other batch job here
Database.executeBatch(new YourOtherBatchClass());
}

and to execute batch job2 10 mins after the batch job1 use scheduling 
mukesh guptamukesh gupta
Hi, 

Please use below code :

ProcessAccs pa= new ProcessAccs();// there should de name of you batch class
String cronStr = '0 0,30 * * * *';
System.schedule('Process Accs Job', cronStr, pa);

run this code in anonymous window.


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
mukesh guptamukesh gupta
Hi,

Please use below code :

ProcessAccs pa= new ProcessAccs();// there should de name of you batch class
String cronStr = '0 0,10 * * * *';
System.schedule('Process Accs Job', cronStr, pa);

run this code in anonymous window.


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh