The exact error when executing the cron job manually (/usr/bin/php -f /var/www/vhosts/ was:

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 7 bytes) in /var/www/vhosts/ on line 290


This error can happen if Magento's cron_schedule table has too many records, coming from the log entries of past cron runs. So, delete all the entries, directly in the database with TRUNCATE TABLE cron_schedule; or using phpMyAdmin or similar.

Now, when calling the cron job again from the command line, it finishes normally, without a crash.


It seems that the table could become that full because in "System -> Configuration -> System -> Cron", "History cleanup every" was set to "1440", thinking this was to be set in minutes. But instead, it seems it's set in days. The same for "Success history lifetime" and "Failure history lifetime" there. So better set all three to some meaningful value like "30".


This "Allowed memory size exhausted" error also persisted after installing the AOE Scheduler module and removing all scheduled cron tasks, then calling the cron job manually. This hinted to the fact that this error is unrelated to any single of Magento's various cron tasks (so also independent of installed contrib modules), and instead happens in Magento core. (This is Magento by the way.)

Also, from searching the error message on the Internet, it appears that the "Allowed memory size exhausted" problem at this specific code location is a rather generic error that else happens for example when processing too many product records at once (see for example here or here).

This had me look at Magento's cron_schedule table, in this case it had 673498 entries according to AOE scheduler (in the database, even 830,881 rows). These were too many records for Pdo.php to process within the memory limits: in line with other reports of the "Allowed memory size exhaused" error in Pdo.php line 290, the error was here caused by too many records in this cron_schedule table.

4 thoughts on “How to fix Magento cron job crashes with “Allowed memory size exhausted at […] Pdo.php on line 290”?

  1. so you mean to say if i will truncate the cron_schedule table it won’t appear.?

    i just tried solution you suggested but it is not working,

    actually i have problem with layered navigation. it is not appearing in category page. i had remove the layered navigation code before . i just added it and i got this error.

    i am not able to add layered navigation again. do you you know to rectify this issue.

    i google it and most of people are saying increase memory_limit and execution time and so.. but i don’t see it working

    how to fix it?

  2. The Pdo.php file seems to be some generic code that deals with database records, and will spit out the "memory exhausted on line 290" error whenever it has to process too many records at once. This can be cron log records like here, product records in other cases, and so on. So it's up to you to find out which table / kind of records it could be in your case with layered navigation. Of course after increasing memory_limit to some reasonably high value like 512 megabytes first … Good luck!

  3. DID ANYONE know how to fix this issues, my website is fine and admin access is fine, when I go to catalog dropdown press category, the window show this following Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 82 bytes) in /home/concon/public_html/lib/Zend/Db/Statement/Pdo.php on line 290

    thanks you

    best regards,
    john ryon

  4. When I made sure the cronjob was able to run -> the error disappears.

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>