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
KruviKruvi 

System.Schedule

Hi

 

Can I run System.Schedule every 1 sec or ever one min?

 

What is the right chron expression to do so. I tried   0 0 * * * ? *    but this runs every hour

 

Please help.

 

Thanks


Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

The smallest hypothetical schedule you can perform with a single Scheduleable interface is once an hour... you may choose when during that hour the code is scheduled to run. Therefore, if you use your maximum of 10 scheduled jobs, you can stagger them to run six minutes apart. However, this will be based on system availability and most likely won't run at this speed (instead running closer to a span of about once per 15 minutes, if my memory serves correctly); you would actually end up with the same code running two or three times once every quarter of an hour instead of the intended effect. If you need a smaller time frame than this, use an external integration, a trigger, or an outbound message (using Workflow Rules). I understand what you're trying to do, but scheduleable classes are not the solution to your problem. When this feature was first introduced, there were many people asking for this same thing, and they were told even then that there were more practical means of achieving "real-time" functionality.

All Answers

sfdcfoxsfdcfox

You can't schedule by the second. As a shared resource, you can't monoplize the servers that way. Best you could possibly get is about 15 minute intervals. Maybe you need a trigger?

KruviKruvi

Thanks

 

How do I get the 15 min interval?

 

My use case is a trigger that causes a class to send a REST callout.

If the other side is "off" or there is no communication the callout is stored in a "queue" on the DB.

I need a process that wakes up in predefined intervals, tries to callout and if it fails continues again after the interval has passed.

The interval does not need to be in seconds but I would like it to be a 1 min interval for example.

 

How do you suggest I do that?

 

Many thanks

 

KruviKruvi

Hi

 

Can someone help and tell me what is the smallest time interval I can schedule a job for and how do I do it using System.schedule?

 

Many thanks

 

 

 

 

sfdcfoxsfdcfox

The smallest hypothetical schedule you can perform with a single Scheduleable interface is once an hour... you may choose when during that hour the code is scheduled to run. Therefore, if you use your maximum of 10 scheduled jobs, you can stagger them to run six minutes apart. However, this will be based on system availability and most likely won't run at this speed (instead running closer to a span of about once per 15 minutes, if my memory serves correctly); you would actually end up with the same code running two or three times once every quarter of an hour instead of the intended effect. If you need a smaller time frame than this, use an external integration, a trigger, or an outbound message (using Workflow Rules). I understand what you're trying to do, but scheduleable classes are not the solution to your problem. When this feature was first introduced, there were many people asking for this same thing, and they were told even then that there were more practical means of achieving "real-time" functionality.

This was selected as the best answer
KruviKruvi

Thanks a lot for your advice, I'll have to figure out what to do about this.