global class LogAutoSendSchedule implements Schedulable {
    public static String logId;
    global void execute(SchedulableContext SC) {
        if(String.isNotEmpty(logId)){
            Id execBTId = Database.executeBatch(new LogAutoSendBatch(logId), 1);
        }else{

            Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
        }
    }

    
    public static void assignOneMinute() {
        // delete 実行済み
        Datetime addOneM = System.now().addMinutes(2);
        String CRON_EXP = '0 ' + addOneM.minute() + ' ' + addOneM.hour() + ' ' + addOneM.day() + ' ' + addOneM.month() + ' ? ' + addOneM.year();
        List<CronTrigger> oldcron = [select Id from CronTrigger where CronExpression = :CRON_EXP and CronJobDetail.Name like 'LogAutoSend%'];
        if (oldcron.size() == 0) {
            System.schedule('LogAutoSend' + CRON_EXP, CRON_EXP, new LogAutoSendSchedule());
        }
        for (CronTrigger ct :
                [SELECT Id FROM CronTrigger WHERE State = 'DELETED' and CronJobDetail.Name like 'LogAutoSend%']) {
            System.abortJob(ct.id);
        }
    }
}