Free Salesforce Developers Tutorials >

Chapter 12 - Governor Limits and Batch Apex >

Schedule Batch Class in APEX

Schedule Batch Class in APEX

What You’ll Learn

S2 Labs

What Is Schedule Batch Class In Apex?

Use the Apex scheduler and the Schedulable interface if you have specific Apex classes that you want to run on a regular basis, or to run a batch Apex job using the Salesforce user interface.

The scheduler runs as system—all classes are executed, whether or not the user has permission to execute the class.

Important: Salesforce schedules the class for execution at the specified time. Actual execution may be delayed based on service availability.

To schedule jobs using the Apex scheduler:

  1. Implement the Schedulable interface in an Apex class that instantiates the class you want to run.
  2. From Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex.
  3. Specify the name of a class that you want to schedule.
  4. Specify how often the Apex class is to run.
  5. For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
  6. For Monthly—specify either the date the job is to run or the day (such as the second Saturday of every month.)
  7. Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job only runs once.
  8. Specify a preferred start time. The exact time the job starts depends on service availability.
  9. Click Save.


You can only have 100 active or scheduled jobs concurrently.

Alternatively, you can call the System.scheduleBatch method to schedule the batch job to run once at a future time.

Once the job has been completed, you can see specifics about the job (such as whether it passed or failed, how long it took to process, the number of records processed, and so on).

Salesforce Developer Training

Example Code Of Schedule Batch Class In Apex

global class ClassName implements Schedulable
     global void execute(SchedulableContext sc)
     BatchClass b = new BatchClass(); // Your batch class

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *