PHP-CLI has maximum execution time clamped at 300 seconds
Hi there,
When running CLI PHP scripts, such as the Symfony console binary, the execution time appears to be clamped at 300 seconds. Calling
,
, or using the
CLI option to override "max_execution_time" all make no difference. (Both increasing and decreasing.) The cPanel account in question is configured to use FPM for PHP via HTTP, which has a 600 second execution limit working fine, but that doesn't apply to CLI execution. Scripts via HTTP can also change their execution time limit as expected. PHP is installed via EasyApache 4. We're using version 7.2 for this account due to reasons.
Calling
within the same CLI script shows the intended figure, but it still closes prematurely at the standard 300 second limit. Where can we adjust this? File
specifies 600 seconds, though this seems to apply to just FPM. Thanks. :)
set_time_limit(),
ini_set("max_execution_time"), or using the
-dCLI option to override "max_execution_time" all make no difference. (Both increasing and decreasing.) The cPanel account in question is configured to use FPM for PHP via HTTP, which has a 600 second execution limit working fine, but that doesn't apply to CLI execution. Scripts via HTTP can also change their execution time limit as expected. PHP is installed via EasyApache 4. We're using version 7.2 for this account due to reasons.
$ which php-cli
alias php-cli='/opt/cpanel/ea-php72/root/usr/bin/php'
/opt/cpanel/ea-php72/root/usr/bin/php
$ php-cli -v
PHP 7.2.32 (cli) (built: Jul 29 2020 17:34:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.32, Copyright (c) 1999-2018, by Zend Technologies
$ php-cli -i | grep max_execution_time
max_execution_time => 0 => 0Calling
echo ini_get("max_execution_time");within the same CLI script shows the intended figure, but it still closes prematurely at the standard 300 second limit. Where can we adjust this? File
/opt/cpanel/ea-php72/root/etc/php.inispecifies 600 seconds, though this seems to apply to just FPM. Thanks. :)
-
Can you run the following rpm -qa |grep php-cli
cat /etc/cpanel/ea4/php.conf
And I'm curious if you've gone over this documentation? EasyApache 4 and the ea-php-cli Package | cPanel & WHM Documentation0 -
Hi Lauren, Thank you for your response. As per your request: # rpm -qa | grep php-cli | sort ea-php56-php-cli-5.6.40-15.15.1.cpanel.x86_64 ea-php71-php-cli-7.1.33-7.7.1.cpanel.x86_64 ea-php72-php-cli-7.2.32-2.2.1.cpanel.x86_64 ea-php73-php-cli-7.3.20-2.2.1.cpanel.x86_64 ea-php-cli-1.0.0-9.9.3.cpanel.x86_64 ea-php-cli-lsphp-1.0.0-9.9.3.cpanel.x86_64 # cat /etc/cpanel/ea4/php.conf --- default: ea-php73 ea-php56: suphp ea-php71: suphp ea-php72: suphp ea-php73: suphp
I'd not seen that documentation. I think this is actually our mistake. The script in question is not a simple single file but class based with inheritance and such. At an earlier point a parent class was callingset_time_limit(300)
before the primary class was callingset_time_limit(3600)
. Either a race condition was occurring whereby the parent class' call was happening after the primary class, or a bug in PHP doesn't accept any subsequent calls toset_time_limit()
after the first. Either way I'm not very confident that cPanel or its PHP-CLI configuration is at fault, though perhaps our mistake and findings will be useful for someone else.0
Please sign in to leave a comment.
Comments
2 comments