我正在尝试安排课程每15分钟运行一次。我知道我们可以每小时设置一次salesforce,但有没有办法将粒度减少到10-15分钟?
global class scheduledMerge implements Schedulable {
global void execute(SchedulableContext SC) {
ProcessTransactionLog p= new ProcessTransactionLog();
p.ProcessTransaction();
}
}
答案 0 :(得分:14)
您可以使用此顶点代码段来安排您的作业每15分钟运行一次。
System.schedule('Job1', '0 0 * * * ?', new scheduledMerge());
System.schedule('Job2', '0 15 * * * ?', new scheduledMerge());
System.schedule('Job3', '0 30 * * * ?', new scheduledMerge());
System.schedule('Job4', '0 45 * * * ?', new scheduledMerge());
答案 1 :(得分:0)
global class scheduledTest implements Schedulable {
global void execute(SchedulableContext SC) {
RecurringScheduleJob.startJob();
String day = string.valueOf(system.now().day());
String month = string.valueOf(system.now().month());
String hour = string.valueOf(system.now().hour());
String minute = string.valueOf(system.now().minute() + 15);
String second = string.valueOf(system.now().second());
String year = string.valueOf(system.now().year());
String strJobName = 'Job-' + second + '_' + minute + '_' + hour + '_' + day + '_' + month + '_' + year;
String strSchedule = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
System.schedule(strJobName, strSchedule, new scheduledTest());
}
}