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
ganeshjujjuruganeshjujjuru 

how can i schedule a class to run every half an hour ...? and also every hour....?

can any body help me how can i schedule a class to run every half an hour ...? and also every hour....? plz send me code..

Peter_sfdcPeter_sfdc

There are two types of classes that support scheduling in Apex. Both implement specific interfaces and methods so that the scheduler can invoke them when needed. 

 

You then use an implementation of cron, or enter in the schedule through the setup menu in the org. 

 

The documentation is quite complete about this. Please see the following sections of the Apex Code Developer guide: 

 

Apex Scheduler: 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

Batch Apex: 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm

 

To summarize, your class will either implement the schedulable interface or the batchable interface. 

 

Either can be scheduled, but you would use batchable if you want to work with larger data sets. Incidentally a schedulable class can also invoke a batchable class as well. So they aren't mutually exclusive. 

 

The code examples are in the links above and give a good starting point. If you make a start but still have problems be sure to post again, but with your specific code and examples, and someone will help you troubleshoot.