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
Khemais MenzliKhemais Menzli 

Best practices to write Scheduler Apex

Hi everyone,
Are there a starting samples to use Scheduler Job in SFDC, I need to plan a job to be started each day at 8:00AM, to copy data from Accounts to opportunities, what is the best practices to write a such Scheduler(should I use a BulkJob+a Scheduler?)
How to test my scheduler before uploading the whole stuff on production environment
Balayesu ChilakalapudiBalayesu Chilakalapudi
Apex Scheduler Notes and Best Practices
  • Salesforce schedules the class for execution at the specified time. Actual execution may be delayed based on service availability.
  • Use extreme care if you’re planning to schedule a class from a trigger. You must be able to guarantee that the trigger won’t add more scheduled classes than the limit. In particular, consider API bulk updates, import wizards, mass record changes through the user interface, and all cases where more than one record can be updated at a time.
  • Though it's possible to do additional processing in the execute method, we recommend that all processing take place in a separate class.
  • 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 your scheduled Apex executes a batch job, callouts are supported from the batch class. See Using Batch Apex.
  • Apex jobs scheduled to run during a Salesforce service maintenance downtime will be scheduled to run after the service comes back up, when system resources become available. If a scheduled Apex job was running when downtime occurred, the job is rolled back and scheduled again after the service comes back up. Note that after major service upgrades, there might be longer delays than usual for starting scheduled Apex jobs because of system usage spikes.
Find more details in