You can scheduled the apex in developer console execute anynomous window
proschedule p = new proschedule(); //Schedule apex class name
String sch = '0 0 8 13 2 ?'; //schedule interval time
system.schedule('One Time Pro', sch, p); //system method to schedule apex class
Check the Time Now, if it is, let's say 10:39 AM, in your clock, then set the minute to 41. This will schedule the job for 10:41 AM just two minutes from now. But, if you set minute value to 38, then it will schedule to next hour 11:38 AM
Try the below code. Follow this process. ======================== Batch Class ============================= global class batchTest1DeleteAccountBefore10 implements database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext bc) { return Database.getQueryLocator('SELECT id,name FROM account WHERE createddate=N_DAYS_AGO:10'); }
global void execute(Database.BatchableContext bc,List<Account> accList) { delete accList; } global void finish(Database.BatchableContext bc) {
} } ======================== Schedule Class =============================
global class batchTes1DeleteAccountBefore10Schedule implements Schedulable { global void execute(System.SchedulableContext sc) { batchTest1DeleteAccountBefore10 test1Obj=new batchTest1DeleteAccountBefore10(); Database.executeBatch(test1Obj); } } ======================== Anonymous Window =============================
batchTes1DeleteAccountBefore10Schedule obj=new batchTes1DeleteAccountBefore10Schedule(); System.schedule('Delete Account before 10 days ago','0 0 8 13 2 ?', obj);
You can run using an anonymous window. You can take reference from the below syntax. ClassName name1= new ClassName (); String cronExp1= '0 0 * * * ?'; System.schedule('Scheduled class', cronExp1, name1);
If you find your Solution then mark this as the best answer.
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex1_2.htm
In that window create a object of your Schdule Apex class then call excute() method passing as null like below
YourScheduleApexClass s=new YourScheduleApexClass();
s.excute(null) ;
Hope it helps YOU!!
Missing an "e".
ScheduleTestClass c = new ScheduleTestClass ();
String sch = '0 0 * * * ?';
System.schedule('Job11', '0 41 * * * ?', c);
SchedulerClassName sch = new SchedulerClassName();
String cronExpression = '0 30 8 1 * * '; // 8:30am every 1st day of the month
System.schedule('EVP Dashboard', cronExpression, sch);
for More Info about cron expressions(Timing Schedule for Cron Codes).
Please visit
http://www.cronmaker.com/
Hope this will help you!
Thanks!
Try the below code.
Follow this process.
======================== Batch Class =============================
global class batchTest1DeleteAccountBefore10 implements database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator('SELECT id,name FROM account WHERE createddate=N_DAYS_AGO:10');
}
global void execute(Database.BatchableContext bc,List<Account> accList)
{
delete accList;
}
global void finish(Database.BatchableContext bc)
{
}
}
======================== Schedule Class =============================
global class batchTes1DeleteAccountBefore10Schedule implements Schedulable
{
global void execute(System.SchedulableContext sc)
{
batchTest1DeleteAccountBefore10 test1Obj=new batchTest1DeleteAccountBefore10();
Database.executeBatch(test1Obj);
}
}
======================== Anonymous Window =============================
batchTes1DeleteAccountBefore10Schedule obj=new batchTes1DeleteAccountBefore10Schedule();
System.schedule('Delete Account before 10 days ago','0 0 8 13 2 ?', obj);
Thanks.
https://www.sfdc-lightning.com/2018/09/batch-class-in-salesforce.html
Hi Santhosh,
You can run using an anonymous window. You can take reference from the below syntax.
ClassName name1= new ClassName ();
String cronExp1= '0 0 * * * ?';
System.schedule('Scheduled class', cronExp1, name1);
If you find your Solution then mark this as the best answer.
Thank you!
Regards
Suraj Tripathi