Print this page

How do I remove CronTrigger table rows with a Deleted State

Knowledge Article Number 000228193
Description When an Apex job (e.g. an Apex class implementing the Schedulable interface) is scheduled in Salesforce, a CronTrigger record is created to represent the scheduled information of a job. For scheduled jobs that run once off or have a specified finite run time, their State field is set to 'DELETED' on completion. Are these jobs automatically purged?
Resolution Presently in Salesforce, there is no automated sweeper job to purge 'DELETED' CronTrigger records after a period of time. As a result, you may find a build up of 'DELETED' CronTrigger records. To take care of these records, you may use System.abortJob(CronTriggerID) to manually purge any CronTrigger record. As per the documentation for System.abortJob(), normally this method is used to stop either an AsyncApexJob or CronTrigger job, however it can also be used to fully purge completed CronTrigger jobs with State='DELETED' from not only the CronTrigger table but also its corresponding records in the CronJobDetail table.

promote demote