I copied an existing scheduler class that we have that runs every hour. I want to do the same thing and run every hour for my batch job. How can I kick it off to actually show up on the scheduled apex page?
I've saved the class in the sandbox and compiled it. However, I can't seem to find where to start it. I've read some posts where it talked about using anonymous apex in the dev console but it never gives examples of what code to use.
How can I start the process to start running in the scheduled apex page?
Example code:
global class NPD_Scheduler_RevenuePipelineSchedule implements Schedulable {
/* Start - Variables */
Integer batchSize;
/* End - Variables */
/* Start - Constructor */
global NPD_Scheduler_RevenuePipelineSchedule(Integer batchSize){
this.batchSize = batchSize;
}
/* End - Constructor */
/*
@MethodName : execute.
@param : SchedulableContext
@Description: This Class calls Batch class
*/
global void execute(SchedulableContext sc)
{
try {
NPD_Batch_RevenuePipelineScheduleUpdater objBatch = new NPD_Batch_RevenuePipelineScheduleUpdater();
System.debug('\n\nSchedule Job');
Database.executeBatch(objBatch, batchSize);
}
catch(Exception e)
{
//Show exception in debug logs if any
System.debug(LoggingLevel.error, '### Exception: ' + e);
}
}
/* End */
public static void scheduleBatch()
{
scheduleBatch(200);
}
/**
* @MethodName : scheduleBatch
* @Param : NA
* @Description: static method to run batch hourly
**/
public static void scheduleBatch(Integer batchSize)
{
System.schedule('Revenue Pipeline Scheduler', '0 0 * * * ?', new NPD_Scheduler_RevenuePipelineSchedule(batchSize));
}
}