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
santhosh  konsanthosh kon 

Hi how to execute schedule apex class from developer console

KaranrajKaranraj
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 this link for more details - 
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex1_2.htm
 
Mani RenusMani Renus
Developer console -->Debug -->Open execute anonymous window 

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!!
 
Tad Aalgaard 3Tad Aalgaard 3
excute should be execute

Missing an "e".
Mani RenusMani Renus
Yes, typo mistake! It's execute ()
Mukesh Kumar 107Mukesh Kumar 107
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
 
ScheduleTestClass c = new ScheduleTestClass ();
String sch = '0 0 * * * ?';
System.schedule('Job11',  '0 41 * * * ?', c);
 
sid.sehgal20sid.sehgal20
You Can Run Directly From Developer Console.

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!
Akshay_DhimanAkshay_Dhiman
Hi Santhosh kon,

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.
farukh sk hdfarukh sk hd
Please mark this as best answer if this helps,

https://www.sfdc-lightning.com/2018/09/batch-class-in-salesforce.html
Suraj Tripathi 47Suraj Tripathi 47

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