How to Schedule Apex to run every 2, 5, 10 minutes in Salesforce

Hello Folks, In this post, I’m going to show you how you can schedule an apex class every 2  minutes or whatever interval you want to set in minutes using the CRON expression.

Schedule Apex every 2 or n minutes in Salesforce

In Salesforce Apex, Scheduling a class every 2 minutes or n minutes is not possible by the standard Salesforce user interface, But you can achieve this by following the below code.

As you are going to schedule an Apex Class so make sure your class implements the schedulable Interface.

Learn more about Salesforce Flow Bootcamp

In this example, I’m scheduling this apex class from the finish method of a batch you can use the scheduling logic as per your logic or scenario.

By doing this you will get a recurring schedule class that executes your logic every n minutes of your choice.

Get complete Roadmap To Learn Salesforce Admin And Development 👇

Share Now

Learn Salesforce Flows 👇 Beginner-friendly course | More than 90+ tutorials

Prepare for PD1 Exam 3 Mock Practice Sets to prepare for the exam

Book a 1:1 Call 👇 Doubt related to Salesforce Flow?

Categories

What’s Trending