global class DNUpsertSchedule implements Schedulable {
|
|
global void execute(SchedulableContext SC) {
|
Id execBTId = Database.executeBatch(new DNUpsertBatch(), 1);
|
}
|
|
public static void assignOneMinute() {
|
// delete 実行済み
|
for (CronTrigger ct :
|
[SELECT Id FROM CronTrigger WHERE CronJobDetail.Name like 'DNUpsert%']) {
|
System.abortJob(ct.id);
|
}
|
Datetime addOneM = System.now().addMinutes(3);
|
String CRON_EXP = '0 ' + addOneM.minute() + ' ' + addOneM.hour() + ' ' + addOneM.day() + ' ' + addOneM.month() + ' ? ' + addOneM.year();
|
List<CronTrigger> oldcron = [select Id from CronTrigger where State = 'WAITING' and CronJobDetail.Name like 'DNUpsert%'];
|
|
if (oldcron.size() == 0) {
|
System.schedule('DNUpsert' + CRON_EXP, CRON_EXP, new DNUpsertSchedule());
|
}
|
|
}
|
}
|