Last active
July 18, 2016 18:48
-
-
Save rtconner/7fd9b78d4f2550bca77d1265f8b07aa3 to your computer and use it in GitHub Desktop.
Delete All Batch Jobs
This file contains 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
global class deletebatch implements Database.Batchable<sObject> { | |
global Database.QueryLocator start(Database.BatchableContext BC) { | |
string txt = 'Bulk Convert Lead Batch'; | |
String query = 'SELECT Id, CronJobDetail.Id, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger WHERE CronJobDetail.Name LIKE \'Bulk Convert Lead Batch%\' LIMIT 150'; | |
return Database.getQueryLocator(query); | |
} | |
global void execute(Database.BatchableContext BC, List<crontrigger> scope) { | |
for(crontrigger a : scope) | |
{ | |
system.abortJob(a.id); | |
} | |
} | |
global void finish(Database.BatchableContext BC) { | |
DateTime nextBatchTime = System.Now().addMinutes(1); | |
String chronExpression = '' + nextBatchTime.second() + ' ' + nextBatchTime.minute() + ' ' + nextBatchTime.hour() + ' ' + nextBatchTime.day() + ' ' + nextBatchTime.month() + ' ? ' + nextBatchTime.year(); | |
batchitupson_schedule clsCRON = new batchitupson_schedule(); | |
System.Schedule( 'deletebatch ' + nextBatchTime, chronExpression, clsCRON); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment