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
v varaprasadv varaprasad 

Schedule Apex with different timings

Hi Everyone.

  i need small help regarding on schedule apex.
  how we will schedule one class with different timings.
EX:i want to schedule one class :  Runs at 4:20; 7:50: 16:20; 20:50 CET these timings.

Thanks in Advance

Alexander TsitsuraAlexander Tsitsura
Hi Varaprasad,

For implement this requirement, you can create list of times and pass this as parametr to shedule job constructor.
Time[] times = new Time[] {
public class scheduledClass implements Schedulable {
  private Time[] times;
  private Integer currIndex;

   public scheduledClass(Time[] times) {
      this.times = times;
      this.currIndex = 0;

   public scheduledClass(Time[] times, Integer currIndex) {
      this.times = times;
      this.currIndex = currIndex;

   public void execute(SchedulableContext sc) {
	final String jobId = String.valueOf(sc.getTriggerId());

        // do logic

       // reshedule job
       final DateTime d = DateTime.newInstance(, times[currIndex]);
       if (d < d.addDays(1);

       // increment index of times
       currIndex = Math.mod((currIndex + 1), times.size());
	d.format('ss mm HH dd MM ? yyyy'),
	new scheduledClass(times, currIndex)

Also you can save times in custom settings.

v varaprasadv varaprasad
Hi Alex.

 Thanks for your is more help full for me.