Things to Remember while working with Apex Scheduler:
- The System.Schedule method uses the user’s timezone for the basis of all schedules, but runs in system mode (i.e. all classes are executed, irrespective of the user’s permissions).
- While scheduling a class from a trigger, the trigger should not add more scheduled job classes than the limit.
- We can have 100 scheduled Apex jobs at one time.
- The maximum number of scheduled Apex executions per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.
- Synchronous Web service callouts are not supported from scheduled Apex. To be able to make callouts, make an asynchronous callout by placing the callout in a method annotated with @future(callout=true) and call this method from scheduled Apex. However, if scheduled Apex executes a batch job, callouts are supported from the batch class.
- Salesforce schedules the class for execution at the specified time. Actual execution may be delayed based on service availability.
- If there are one or more active scheduled jobs for an Apex class, we cannot update the class or any classes referenced by this class through the Salesforce user interface. However, we can enable deployments to update the class with active scheduled jobs by using the Metadata API (for example, when using the Salesforce extensions for Visual Studio Code).
- We can programmatically query the CronTrigger and CronJobDetail objects to get the count of Apex scheduled jobs.
- Though it’s possible to do additional processing in the execute method, but for best practices all processing should take place in a separate class.