If you are getting error "MAXIMUM_EXECUTION_LIMIT_EXCEEDED xx seconds" via notification of the cron daemon or while executing the cron, here is the reason and solution on it.
Reason :
cPanel server uses settings in global "php.ini" file while executing the cron jobs configured under any user. The parameter "max_execution_time" is set to 30 seconds in global php.ini on most of our servers. Crons which requires time more than 30seconds to execute, will face this error. It is not possible to increase the execution time in global php.ini beyond certain limit as it will affect server performance.
Solution :
Set the cron with "-c" paramenter passed to "/usr/local/bin/php" followed by path for customized php.ini set under user document root. Parameter "-c" will fetch the settings from customized php.ini and same will be applicable while execution of the cron job.
the cron job/command whould be somethink like this
================================================== ========
* * * * * /usr/local/bin/php -c /home/user/path/to/php.ini /home/user/path/to/cron.php
================================================== ========
Note : - Path must contain php.ini.
- Be sure that the cron job is not overloading the server even if it is taking long for the execution.
- Configure such kind of cron jobs to execute in the late night when there is less traffic on the server.
- This could be the solution for all the errors raised due to restricted values of the parameters in global php.ini.
Reason :
cPanel server uses settings in global "php.ini" file while executing the cron jobs configured under any user. The parameter "max_execution_time" is set to 30 seconds in global php.ini on most of our servers. Crons which requires time more than 30seconds to execute, will face this error. It is not possible to increase the execution time in global php.ini beyond certain limit as it will affect server performance.
Solution :
Set the cron with "-c" paramenter passed to "/usr/local/bin/php" followed by path for customized php.ini set under user document root. Parameter "-c" will fetch the settings from customized php.ini and same will be applicable while execution of the cron job.
the cron job/command whould be somethink like this
================================================== ========
* * * * * /usr/local/bin/php -c /home/user/path/to/php.ini /home/user/path/to/cron.php
================================================== ========
Note : - Path must contain php.ini.
- Be sure that the cron job is not overloading the server even if it is taking long for the execution.
- Configure such kind of cron jobs to execute in the late night when there is less traffic on the server.
- This could be the solution for all the errors raised due to restricted values of the parameters in global php.ini.