Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we schedule a class to run every 15 minutes in salesforce?

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();
   }
}
like image 216
Prady Avatar asked Feb 03 '12 10:02

Prady


People also ask

Can we schedule a batch class scheduler class in every 5 minutes?

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.

How do I schedule a class in Salesforce?

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).

How can we schedule batch class to run in future only once from the specified minutes from current time?

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.


1 Answers

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());
like image 74
Rajesh Avatar answered Oct 12 '22 17:10

Rajesh