1

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:

  1. Why a scheduling class does not execute on time when we schedule it through developer console say for next day and every day.
  2. 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.

4
  • Thanks to everyone for editing the question.Can anyone provide me the solution please as it is very important for me to resolve. I have checked the debugs and all but nothing bad is there.
    – Rohit
    Commented Jun 17, 2014 at 10:51
  • Are you trying in free developer account? Scheduled jobs are depending on the server time where your instance related to. There would be time lag definitely. So, you may need to adjust your scheduling time according to the server time.
    – Bforce
    Commented Jun 17, 2014 at 13:18
  • @Baskaran : No No, it is an Enterprise edition. I have adjusted the same. The problem is getting bigger and bigger. Now customers are receiving repetitive SMSs.
    – Rohit
    Commented Jun 18, 2014 at 7:13
  • To add to above reply as I have written that we have 2 more scheduling jobs now I find out that one of the scheduling job is always missing to execute on daily basis. There is 20-30 minutes gap in between them. Why is it so.
    – Rohit
    Commented Jun 18, 2014 at 7:16

2 Answers 2

1

I had a similar issue that was confusing me. It looked liked it was completing successfully (I used debug logs) but checking the records it hadn't actioned. I spent a couple of days working salesforce support and they eventually found I was hitting a governor limit that was not showing anyway on our end (not in the same debug logs or the apex jobs page). I was hitting a time out on a query, I don't know if you are hitting the same but what I learnt is that we don't seem to get all the information when it comes to scheduled jobs.

If you can see if salesforce support can provide this extra information. As I said it took us a couple of days to pin it done then even.

For reference the scheduled jobs page will continue to say queued while the end date is in the future and further runs are scheduled.

1
  • Ok Girbot I will chk from them.
    – Rohit
    Commented Aug 30, 2014 at 5:32
1

Format is actually:

<seconds> <minutes> <hours> <day_of_month> <month> <day_of_week> <optional_year>

For example:

string s3 = ' 0 30 * * * *';

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .