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
SIVASASNKARSIVASASNKAR 

How to delete the previous scheduled jobs through Apex

Hi All,

 

Can any one help me,

 

I have a problem with the schedule jobs, i have total 50 jobs. in this I want to delete the firsh 25 jobs which were not scheduled next time. I am using timestamp wile scheduling the job.

Ex:

 

Job 1 cronExpression='0 5 10 5 2013 ';

Job 2 cronExpression='0 10 10 5 2013 ';

Job 3 cronExpression='0 15 10 5 2013 ';

Job 4 cronExpression='0 25 10 5 2013 ';

Job 5 cronExpression='0 30 10 5 2013 ';

....

like up to

job 20

I want to delete from job1 to job 10;

 

 

please suggest me.

Best Answer chosen by Admin (Salesforce Developers) 
sushant sussushant sus
eg:



String SCHEDULE_NAME = 'test'; id cronid = System.schedule(SCHEDULE_NAME, '0 15 0-23 * * ?', new scheduledMaintenance()); System.abortJob(cronid);

All Answers

sushant sussushant sus
eg:



String SCHEDULE_NAME = 'test'; id cronid = System.schedule(SCHEDULE_NAME, '0 15 0-23 * * ?', new scheduledMaintenance()); System.abortJob(cronid);
This was selected as the best answer
SIVASASNKARSIVASASNKAR

Cheers Sushant !!

 

It is working..