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
RiothamusRiothamus 

Scheduling jobs to run every few minutes

Hi,

 

I have a background job that needs to run every few minutes to populate a database (there are multiple database and HTTP calls, so it needs to be run in increments to stay under Salesforce limits), but the Salesforce setup page doesn't allow scheduling jobs except weekly or monthly.

 

Is there a way around this? I was thinking of having the job get the current time, add 5 minutes, and then schedule the next job before it does its work.

 

Are there better solutions?

 

Sridhar BonagiriSridhar Bonagiri

Hi,

 

You can achieve this through cron expression.

 

For more details please go through the below link.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

Regards,

Sridhar Bonagiri

 

sfdcfoxsfdcfox

While the original response is correct, please be mindful that execution windows are "as available" (execution may be delayed a few minutes), and you will be unable to schedule any more frequently than about 7 minutes, because, like CRON, the batch handler thread only wakes up periodically to perform actions; it does not constantly monitor the database for actions that need to be performed.