Magento 1 Cron – Fix MySQL Server Has Gone Away Error in Cronjobs

crondatabaseerrormagento-1

we suddenly have an error in the cronjob.

error message:

a:4:{i:0;s:63:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away";i:1;s:1334:"#0 /html/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(305): PDO->beginTransaction()

<#1 /html/magento/lib/Zend/Db/Adapter/Abstract.php(495): Zend_Db_Adapter_Pdo_Abstract->_beginTransaction()

<#2 /html/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(219): Zend_Db_Adapter_Abstract->beginTransaction()

<#3 /html/magento/app/code/core/Mage/Core/Model/Resource/Abstract.php(76): Varien_Db_Adapter_Pdo_Mysql->beginTransaction()

<#4 /html/magento/app/code/core/Mage/Core/Model/Abstract.php(313): Mage_Core_Model_Resource_Abstract->beginTransaction()

<#5 /html/magento/app/code/community/Aoe/Scheduler/Model/Observer.php(112): Mage_Core_Model_Abstract->save()

Best Answer

This Error comes due to your code script not reach the server Database. you need to normalize your code script, also need to increase the server execution time. Get your server execution time with To know about the server php features phpinfo(); function and put a small code above your cron job file max_execution time also by

<?php
ini_set('max_execution_time', 180); // Set max execution time explicitly.
?>