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
Rahul 168Rahul 168 

Scheduling a Batch job at a particular time

Best Answer chosen by Rahul 168
Ajay K DubediAjay K Dubedi
Hi Rahul,

Please refer to the below code.

 String day = string.valueOf(system.now().day());
 String month = string.valueOf(system.now().month()); 
  String hour = string.valueOf(system.now().hour());
 String minute = string.valueOf(system.now().minute() + 1);
 String second = string.valueOf(system.now().second());
 String year = string.valueOf(system.now().year()); 
 String strSchedule = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
 System.schedule('Sample Job', strSchedule, new sampleapexbatch());

Thanks,
Ajay Dubedi