Check the class descriptions .....
/** * This is a simple class called from scheduler class. * **/ public class AffectedScheculeClassExample { public AffectedScheculeClassExample() { System.debug('Calling from scheduler class for testing ...... '); } }
/** * This is a scheduler class example. * This class implements the Schedulable interface for a class called AffectedScheculeClassExample. * * Link: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm **/ global class ScheduledClassExample implements Schedulable { //This is implemented method and it must be declared as global or public. global void execute(SchedulableContext sc) { AffectedScheculeClassExample affectedSchClassExmpl = new AffectedScheculeClassExample(); } }
/** * This class is responsible for calling scheduler class named as ScheduledClassExample to run at schedule time. * Call this class constractor from anonymous window. **/ public class CallScheduledClassExample { //Constructor need to be call from annonymous window to run the schedule job. public CallScheduledClassExample(){ ScheduledClassExample schClsExmpl = new ScheduledClassExample(); /** * Schedule structure: * <Seconds> <Minutes> <Hours> <Day_of_month> <Month> <Day_of_week> <Optional_year> * * For below example it will schedulw the job @ 02:28 AM every day. */ String sch = '0 28 2 * * ?'; String schJobID = system.schedule('Scheduler Example', sch, schClsExmpl); } }
To test this example instantiate CallScheduledClassExample()
from anonymous window as,
CallScheduledClassExample inst = new CallScheduledClassExample();