Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete all schedule jobs in an org.
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]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment