Hello Everyone, In this post, I am going show you, how you can delete or abort a scheduled or cron job using apex code. Salesforce doesn't expose API to delete scheduled or cron job, Until now it allows us to abort job. So let's begin,

Delete scheduled jobs using apex

By using following code sample you can delete scheduled jobs via developer console or you can used in you apex handler according to business model.

Delete all jobs:

 for(CronTrigger ct:[SELECT Id, CronJobDetail.Name FROM CronTrigger]){
System.abortJob(ct.Id);
}
Delete a particular job:
 //replace jobId with your scheduled job id
CronTrigger ct:[SELECT Id, CronJobDetail.Name FROM CronTrigger WHERE Id=:jobId];
System.abortJob(ct.Id);

Query scheduled job using developer console:

Hope you like this post, for any query or suggestions please feel free to comment.

Thank you.