Magento 2 – Maximum Execution Time of 300 Seconds Exceeded

databasemagento2.2.2server-setupsetup-upgrade

I am upgrading a website from Magento 2.2 to 2.5 and running into an error. I read through a lot of threads and forums but nothing is working. This includes adding

max_execution_time 60000, set_time_limit(0) in my php.ini

I am using Cloudways and they said any PHP directives defined in a .htaccess will not be used. To use PHP-FPM Settings.

I added the following values:
enter image description here

I restarted my server and looked into my phpinfo() and saw the changes I made were the same values in the image attached.


Preconditions

  1. Running Magento 2.2.2, upgrading to 2.2.5
  2. I have 1 website 1 store 4 store views. Over 250k orders and about 400 products.

Steps to reproduce

  1. composer require magento/product-community-edition 2.2.5 –no-update
  2. composer update
  3. rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/*
  4. php bin/magento setup:upgrade

Expected result

  1. The Magento 2.2.2 upgrades to 2.2.5.

Actual result

  1. Time to upgrade takes longer than 300 seconds.
  2. The maximum execution time of 300 seconds exceeded in /home/150747.cloudwaysapps.com/qqemzvkvdx/public_html/vendor/magento/frame
    work/ObjectManager/Factory/AbstractFactory.php on line 111

Thanks for reading. Anything helps!

Best Answer

Please try to run this

php -d max_execution_time=252900 memory_limit=10G  bin/magento setup:upgrade

instead of

php bin/magento setup:upgrade

It will override your PHP env value during upgrade command.

Also, Stop all Cronjob during the upgrade process. And Before start upgrade process delete this two files .setup_cronjob_status,var/.update_cronjob_status from var/

Related Topic