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
Scott0987Scott0987 

Schedule apex job

Is there a way to schedule an apex job to run everyday at 5pm? 

Best Answer chosen by Admin (Salesforce Developers) 
Scott0987Scott0987

I apreciate all of the answers.  I also realized that if you use "implements Schedulable" in the class and then have a "execute(SchedulableContext SC)" section you can go to apex classes and then click on the schedule button.  thanks for all the help.  

All Answers

Dev@Force.ax647Dev@Force.ax647

JobClass m = new JobClass();

String seconds = '0'; //Execute at Zero Seconds
String minutes = '0'; //Execute at 0th minute of hour
String hours = '17'; // Execute at 5pm
String dayOfMonth = '*'; // Execute Every Day of the Month
String month = '*'; // Every MOnth
String dayOfWeek = '?'; //Execute on all 7 days of the Week
String year = '*'; //Execute every year

//Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
String sch = seconds + ' ' + minutes + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ' + dayOfWeek + ' ' + year;

system.schedule('Job at 5pm every day ', sch, m);

hkp716hkp716

String sch = '0 0 17 * * ?';

system.schedule('Job at 5pm every day ', sch, m);

sivaextsivaext

hi 

 

you need to write three lines of code in developer console

 

  Classname cl = new classname();

  String sc ='0 0 17 * * ?';

System.schedule("some name" , sch, sc);

 

it will runs everyday at 5pm.

 

 check this link also

 

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

 

Scott0987Scott0987

I apreciate all of the answers.  I also realized that if you use "implements Schedulable" in the class and then have a "execute(SchedulableContext SC)" section you can go to apex classes and then click on the schedule button.  thanks for all the help.  

This was selected as the best answer