I have the same problem which this guy faced and came with a solution. I am not fully satisfied with the solution . The same happen to me that my Apex job does remain as 'Queued' and many times never execute at all. Ricky Hewitt, provided a solution which is static in my view. Am I right.
My question are:
- Why a scheduling class does not execute on time when we schedule it through developer console say for next day and every day.
- Why it always executed when I checked it doesn't and then executes after I schedule it again after 5 minutes of knowing it has not.
I have 2 more class which are set for scheduling and there is gap of 30 minutes in between them. My code is:
global class LeadReminderSchedule implements Schedulable{
list<Lead> schedule = new list<Lead>();
global void execute(SchedulableContext ctx)
{
try{
CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
FROM CronTrigger
WHERE
Id = :ctx.getTriggerId()];
system.debug('--cron expression--'+ct.CronExpression);
system.debug('-cron trigger run--'+ ct.TimesTriggered);
LeadReminderMail lrm = new LeadReminderMail();
lrm.sendMail();
LeadReminderBatchSMS lrbs = new LeadReminderBatchSMS();
Integer scopeSize =100;
Database.executeBatch(lrbs, scopeSize);
}
}
I scheduled it from developer console.
LeadReminderSchedule lrs3 = new LeadReminderSchedule();
string s3 = '0 29 10 * * ?';
system.schedule('Daily Reminder Lead',s3,lrs3);
Even it does not come into queue. Because whenever it comes into queue it gets executed.