Running a scheduled job every 1 minute and 15 miutes.
1) 1 Minute logic:
i)
ClassName cls = New ClassName();
String myDateTime = String.Valueof(datetime.now().addseconds(10));
String[] strs =myDateTime.split('-',5);
String[] strs2=strs[2].split(':',5);
String[] strs3=strs2[0].split(' ',3);
String schdul= strs2[2]+' '+strs2[1]+' '+strs3[1]+' '+strs3[0]+' '+strs[1]+' '+'?';
system.schedule('jobid',cls,wfbatch);
ii)
ClassName cls = New ClassName();
Datetime dt = DateTime.now();
Integer nextMinute = dt.minute() + 1;
if (nextMinute > 59) {
nextMinute -= 60;
}
String scheduleString = '1 ' + nextMinute + ' * * * ? *';
system.debug('-------'+scheduleString);
system.schedule('jobid',cls,wfbatch);
2) 15 Minute logic:
System.schedule('Scheduled Job 1', '0 0 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 2', '0 15 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 3', '0 30 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 4', '0 45 * * * ?', new ScheduledClass());
Note:
global class Scheduler02 implements Schedulable {
global void execute(SchedulableContext SC){
//Call other class method which will perform operations as it is
//recommended that all processing take place in a separate class
doScheduling();
}
public void doScheduling(){
try{
dateTime dt=System.now().addMinutes(10);
String Csec,Cmin,Chr,Cday,Cmonth,CYear;
Csec=String.valueof(dt.second());
Cmin=String.valueof(dt.minute());
Chr=String.valueof(dt.hour());
Cday=String.valueof(dt.day());
Cmonth=String.valueof(dt.month());
CYear=String.valueof(dt.Year());
String SchTimer=Csec+' '+Cmin+' '+Chr+' '+Cday+' '+Cmonth+' ? '+CYear;
system.debug('*************SchTimer:'+SchTimer);
Scheduler01 cas = new Scheduler01();
system.schedule('Scheduler01: Running at '+System.now().format(), SchTimer, cas);
//we will delete completed apex scheduled jobs for which state is DELETED
for( CronTrigger c:[Select State,Id,EndTime,CronExpression From CronTrigger
where NextFireTime=null AND State='DELETED' Limit 100]){
System.abortJob(c.id);
}
}
catch(exception e){
}
}
}
Casinos Near Casinos Near Casinos Near Me - Mapyro
ReplyDeleteWith casinos located in your area, you're 김천 출장마사지 sure to get a taste for 군포 출장샵 the 용인 출장마사지 best slot machines in the USA. Casino Casinos With Casinos Near 익산 출장샵 Me - 양산 출장샵 Mapyro.