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.

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.

Spread the love

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *