Magento 1.9.2.1 – Cron Not Working

cronmagento-1.9

Cron has been an issue ever since 1.8/1.9 or whenever Magento made cronjobs mandatory. I've done everything I could possible do and am at my wits end. I'm seriously considering doing a fresh install of Magento and starting all over. I'm calling cron by both cron.sh and cron.php. I've modified cron.php and added $isShellDisabled = true; where it needs to be. I've installed AOE Scheduler. With that extension, I can see everything scheduled that is never executed. I checked the cron_schedule table in the database and it is constantly empty no matter what I do. I've checked with the host provider and they inform me that cron is executing properly. I've even changed the permissions of cron.php and cron.sh to 7, 5, 5.

I get these emails…

Cron error while executing core_email_queue_send_all:

exception 'Mage_Core_Exception' with message 'Too late for the schedule.' in /home/lbingman/public_html/app/Mage.php:595 Stack trace:
#0 /home/lbingman/public_html/app/code/community/Aoe/Scheduler/Model/Observer.php(47): Mage::throwException('Too late for th...')
#1 /home/lbingman/public_html/app/code/core/Mage/Core/Model/App.php(1357): Aoe_Scheduler_Model_Observer->dispatch(Object(Varien_Event_Observer))
#2 /home/lbingman/public_html/app/code/core/Mage/Core/Model/App.php(1336): Mage_Core_Model_App->_callObserverMethod(Object(Aoe_Scheduler_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
#3 /home/lbingman/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#4 /home/lbingman/public_html/cron.php(76): Mage::dispatchEvent('default')
#5 {main}

I'm not sure what to make of them. I've missed an order by a few days because I was never notified by email.

UPDATE: Just as I type this, I see that cron was just executed and I received a test email that I sent myself via a test order. However, the cronjob was scheduled to run at 1:38AM and I saw in AOE Scheduler that the cronjob was executed at 1:45AM. This boggles my mind because I have cronjobs on the server set to run every minute.

Just when I think I may have the problem nailed down to one area, something else happens to completely throw me off again. Does anyone have any idea what is going on? I can't believe I'm the only one having this problem.

EDIT: I should note that when I manually execute cron.php by typing in the link to it in the web browser, cron executes and all of the past unexecuted tasks show up as "Success" in the AOE Scheduler extension.

Best Answer

What is your server timezone set as? And what's your Magento global config timezone?

Too late for the schedule. errors can happen because of discrepancies between these two settings.

Also check out this article: https://support.hypernode.com/knowledgebase/magento-utc-hypernode/

The timezone nut is actually not that hard to crack. But Magento has some internals that loose the sense of timezones by converting to and from an ancient time format called the Unix Time. This is a time format does not have a sense of time zones.

This problem crops up when calculating stuff involving dates and shows up as weird problems like:

  • Catalog price rules will disappear after a few hours.
  • Magento crons email your with the error “Too late for schedule”.

All of this is because MySQL and Magento do not agree on the timezone to use and also do not communicate correctly.

To solve this problem, Magento should operate on the same timezone as the server. Then, to display all dates and times on your websites and stores as you like them, set the timezone for all websites to your preferred timezone.

Related Topic