I am trying to schedule a class to run every 15 minutes. I know we can set in salesforce for every hour, but is there a way to reduce the granularity to 10-15 minutes?
global class scheduledMerge implements Schedulable {
global void execute(SchedulableContext SC) {
ProcessTransactionLog p= new ProcessTransactionLog();
p.ProcessTransaction();
}
}
You can schedule that class using cronExpression to be executed every 5 minutes of every hour. OR you don't want to implement the Schedulable interface at all in any class. Exactly.
From Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex. Specify the name of a class that you want to schedule. Specify how often the Apex class is to run. For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
Batchable , you can also use System. scheduleBatch to run a batch X minutes in the future. This negates the need for a scheduled class entirely. You can also daisy chain these together if you want to run perpetually every X minutes by calling the batch again in the finish method.
You can use this apex code snippet to schedule your job to run every 15 minutes.
System.schedule('Job1', '0 0 * * * ?', new scheduledMerge());
System.schedule('Job2', '0 15 * * * ?', new scheduledMerge());
System.schedule('Job3', '0 30 * * * ?', new scheduledMerge());
System.schedule('Job4', '0 45 * * * ?', new scheduledMerge());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With