Are there best practices to get scheduled apex scheduled to run faster than once per hour?

When trying to set up a schedule to run every 5 minutes I got an error that seemed to indicate that you can’t schedule apex to run every X minutes or every Y seconds. It appears the fastest you can go is once per hour.

Are there any best practices to get around this limitation (say, scheduling the job a few times) or is this restriction something that should really be adhered to?

You can have a max of 10 scheduled jobs – so theoretically if you only had 1 job that needed to run you could schedule 10 jobs, each starting 6 minutes apart. Not sure if that would work so well in practice, though.

Answer

The limit is now 25 shceduled jobs instead of 10, meaning once every 2.4 minutes instead of 6 is the new maximum.

It is also possible to start a batch job from a scheduled apex job and then schedule a new job from batch apex opening the door to infinite chains of execution. If your batch job implements Database.Stateful it’s even possible to persist object state between these!

If you’re looking to write a little less code yourself I saw a post about an app called Skoodat Relax that may be worth looking into although I have little personal experience with it.

Last but not least there’s the off-platform option of using an external service, say a simple timer app on heroku or even a *nix cron job that does a callout to your salesforce org on whatever schedule you want.

Attribution
Source : Link , Question Author : Ryan Elkins , Answer Author : ca_peterson

Leave a Comment