I have a Magento e-commerce with 60.000+ products. Every night some crons are executed for the synchronization of the catalog with the management tool.

During the night I found two types of errors about cron execution:

1. PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away'

2. PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 202312905 bytes)

Searching information about these errors I found that maybe are linked with PHP configuration of the variables memory_limit and max_execution_time.

Can you help to find the cause of these errors?

If the cause is the PHP configuration, can you give me an advice about a possible configuration for a Magento e-commerce of 60.000+ products?(max_execution_time, max_input_time, memory_limit, wait_timeout, connect_timeout).

Thanks in advance


3 Answers 3


1. Try to change my.cnf

max_allowed_packet = 16M
wait_timeout = 1800 
connect_timeout = 120

And you will need to restart your MySQL server

2. Memory limit for PHP can be configured in following places:

  • php.ini
  • .htaccess file
  • php scripts

In the htaccess there are these lines:

php_value memory_limit 512M
php_value max_execution_time 38000

Or In PHP.ini:

memory_limit 512M

These errors are probably related to the size of the dataset that is parsed when running the cronjob. I'd suggest you increase the max execution time to roughly about what you expect the cronjob takes in time. The memory limit can be increased based on the maximum memory your server is capable off. I'd suggest doubling what is there now and see whether or not it's enough. Also check if you're not running more than one cronjob at a time. If there's multiple running at the same time using both the same dataset each with this size it could also lead to problems like yours.


Theres a couple ways of handling this, either increase memory limits and max_execution_time in htaccess.

Or try adding the following code at the top of your cron php file:

ini_set('memory_limit', '-1');


Not the answer you're looking for? Browse other questions tagged or ask your own question.