Too late for the schedule

Viewed 3265

When Cron with "newsletter_send_all" this job code execute then its status became missed and pass message like below. currently using magento's defalt cron settings with UTC time. My Cron.php executed in every 5 minute. Please help me out on this curios issue.

    exception 'Mage_Core_Exception' with message 'Too late for the schedule' in /home/test/public_html/app/Mage.php:595
    Stack trace:
    #0 /home/test/public_html/app/code/core/Mage/Cron/Model/Observer.php(293): Mage::throwException('Too late for th...')
    #1 /home/test/public_html/app/code/core/Mage/Cron/Model/Observer.php(72): Mage_Cron_Model_Observer->_processJob(Object(Mage_Cron_Model_Schedule), Object(Mage_Core_Model_Config_Element))
    #2 /home/test/public_html/app/code/core/Mage/Core/Model/App.php(1338): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer))
    #3 /home/test/public_html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Cron_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
    #4 /home/test/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
    #5 /home/test/public_html/cron.php(75): Mage::dispatchEvent('default')
    #6 {main}

Also made below modification in newslatter module's observer in core for testing purpose but still its not working

    public function scheduledSend($schedule)
    {
        $countOfQueue  = 1; // default 3 Modified on 14 Nov 17
        $countOfSubscritions = 1; //default 20 Modified on 14 Nov 17

        $collection = Mage::getModel('newsletter/queue')->getCollection()
            ->setPageSize($countOfQueue)
            ->setCurPage(1)
            ->addOnlyForSendingFilter()
            ->load();

        $collection->walk('sendPerSubscriber', array($countOfSubscritions));
    }
1 Answers

This happens when the scheduler finds pending jobs that were supposed to be scheduled longer than the time configured in 'system/cron/schedule_lifetime'. By default this value is set to 15 minutes.

There are two different problems the may result in you seeing this error:

  1. Cron isn't configured to run often enough: If you don't trigger cron often enough then the tasks start piling up and most likely tasks will be too late for schedule at the point when they're being executed by the scheduler. Instead of increasing the scheduler_lifetime settings you should increase the frequency cron is being called to */5 * * * * (every 5 minutes) or even * * * * * (every minute).
  2. You have long running cron jobs that will block the execution of other jobs: In case you're importing data, indexing products, generating reports or doing other long-running jobs via cron (which is generally a good idea) other jobs will not be run in parallel (unless you're running cron.php instead of cron.sh). This will result in these jobs not being executed. Find out which jobs are preventing others from running (by looking at the timeline view) and run them in a different cron group. (look at this for more information and check the features added to version >0.5.0 for an easier way to configure and manage cron groups.

source https://github.com/AOEpeople/Aoe_Scheduler/blob/master/doc/faq.md

Related