- Running this code will delete ALL scheduled jobs in the organization
- You will need to reschedule all jobs manually after running this
- If you are unsure of the impact of this, please contact your internal development team
- If you wish to use ScheduleJob ID instead of cronTrigger ID to abort the job using System.AbortJob() use API version 32.0 or below
List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId,
PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey from CronTrigger
where State = 'Waiting' or State='Running'];
System.debug('No of jobs: '+listCronTrigger.size());
If (listCronTrigger.size() > 0)
{
for (Integer i = 0; i < listCronTrigger.size(); i++)
{
System.abortJob(listCronTrigger[i].Id);
System.debug('Job details ::'+String.valueOf(listCronTrigger[i]));
}
}
No comments:
Post a Comment