Last active
January 30, 2018 11:04
-
-
Save samuel-alves/6eb67c48e8b9305b4805b70a2cb01805 to your computer and use it in GitHub Desktop.
Abort scheduled jobs.
#salesforce #apex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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