Build an Apex class implementing Schedulable, schedule it with a cron expression, and verify it runs on the expected cadence.
- Write the Schedulable class
Create an Apex class implementing the Schedulable interface. The execute method takes a SchedulableContext and runs your logic (typically calls Database.executeBatch on a Batch Apex class).
- Write a unit test
Test the schedulable class by calling System.schedule inside Test.startTest and Test.stopTest. The test confirms the schedule registers without an exception.
- Deploy the class
Deploy through Salesforce DX, change set, or Developer Console. Confirm Apex Test coverage stays above the 75 percent platform minimum.
- Schedule the job
Open Setup, Apex Classes, click Schedule Apex. Choose the class, set the frequency (Weekly, Monthly, specific cron), and the start time. Save.
- Monitor the first run
Open Setup, Scheduled Jobs. The scheduled job appears with the next run timestamp. After the first run, open Apex Jobs to confirm completion.
- Set up failure alerts
For production jobs, add try/catch logging to the execute method that writes failures to a custom Apex Log object or sends an email to ops. Silent failures are the most common scheduled job incident.
Code-based scheduled execution using the Schedulable interface and a cron expression.
Declarative scheduled automation built in Flow Builder; preferred for no-code patterns.
Scheduled job that writes a source report to a target object for historical trend analysis.
Opportunity line item feature that splits revenue across time periods for subscription modeling.
Time-pattern syntax for fine-grained scheduling in Scheduled Apex.
- Salesforce caps scheduled Apex jobs at 100 per org. A team that schedules many small jobs hits the cap; consolidate through a master scheduler that dispatches.
- Cron expressions in Salesforce use seven fields (seconds-minutes-hours-day-month-dayofweek-year). Linux cron uses five; do not paste a Linux cron directly.
- Scheduled jobs in a paused org still queue but do not execute until the org resumes. After a sandbox refresh, scheduled jobs may need to be re-registered.
- Revenue Schedule cannot coexist with Quantity Schedule on the same product. Enable one or the other based on how you model subscription revenue.
Keep the related term in your library so you can find this topic again.