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
Admin ProcessAdmin Process 

Execute of a class 3 times a day

How can I program the execution of a class 3 times a day at 30 minutes after the hour?

For example:

7:30 hrs
12:30 hrs
19:30 hrs

Please help me with the code completed I am begginer of code apex.
Best Answer chosen by Admin Process
Raj VakatiRaj Vakati
To schedule an Apex class to run at regular intervals, first write an Apex class that implements the Salesforce-provided interface Schedulable.
The scheduler runs as system—all classes are executed, whether or not the user has permission to execute the class.
To monitor or stop the execution of a scheduled Apex job using the Salesforce user interface, from Setup, enter Scheduled Jobs in the Quick Find box, then select Scheduled Jobs.


The following example implements the Schedulable interface for a class called mergeNumbers:
 
global class scheduledMerge implements Schedulable {
   global void execute(SchedulableContext SC) {
      mergeNumbers M = new mergeNumbers(); 
   }
}


The following example uses the System.Schedule method to implement the above class.
 
scheduledMerge m = new scheduledMerge();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('Merge Job', sch, m);



https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

https://www.appseconnect.com/apex-scheduler-in-salesforce/
https://www.tutorialkart.com/learn_apex/apex-scheduler-syntax-methods/
https://www.janbasktraining.com/blog/what-is-scheduled-apex/

All Answers

Naren9Naren9
Hi admin,
You schedue the apex job to execute at specified time.
Below are the more details:
1. Asynchronous Apex job call.
More details on this 
https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_scheduled

Thanks,
Naren
Raj VakatiRaj Vakati
To schedule an Apex class to run at regular intervals, first write an Apex class that implements the Salesforce-provided interface Schedulable.
The scheduler runs as system—all classes are executed, whether or not the user has permission to execute the class.
To monitor or stop the execution of a scheduled Apex job using the Salesforce user interface, from Setup, enter Scheduled Jobs in the Quick Find box, then select Scheduled Jobs.


The following example implements the Schedulable interface for a class called mergeNumbers:
 
global class scheduledMerge implements Schedulable {
   global void execute(SchedulableContext SC) {
      mergeNumbers M = new mergeNumbers(); 
   }
}


The following example uses the System.Schedule method to implement the above class.
 
scheduledMerge m = new scheduledMerge();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('Merge Job', sch, m);



https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

https://www.appseconnect.com/apex-scheduler-in-salesforce/
https://www.tutorialkart.com/learn_apex/apex-scheduler-syntax-methods/
https://www.janbasktraining.com/blog/what-is-scheduled-apex/
This was selected as the best answer
Admin ProcessAdmin Process
Hi Raj,

The shared information was very helpful, I solved my problem.

Thanks in advance.

Regards.