
Here's a test script that should exit after 5s: =0 $i++) () /home/tom/MailChap/timeout_test. If you avoid the sleep system call, set_time_limit(5) should work fine in CLI scripts.

PHP TIME LIMIT PHP.INI WINDOWS
This is not true on Windows where the measured time is real. is not included when determining the maximum time that the script has been running. The maximum execution time is not affected by system calls, stream operations etc.Īnd the docs for set_time_limit() say this:Īny time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. The docs for max-execution-time say this: In your test script you used sleep(5) to test long running execution time but that is not a valid test. is not included when determining the maximum time that the script has been runningĬheck out a very similar question asked on Stack Overflow: Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, etc. The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Regarding using a sleep loop to test this, I learned that it won't work. However, it appears that any max_execution_time set in /etc/php.ini actually will not affect the CLI scripts - even if the file is being properly loaded (use phpinfo() to find out) - so you must use one of the other methods mentioned above. Method 1: Edit file wp-config.php: Add the following to wp-config.php: settimelimit(30000) Method 2: Edit file. That file also needs to be readable by the user who is running the php script, so if it was created by root and a user can't "read" it, that means php probably can't "read" it either. To answer my question about where the php.ini file would be loaded from, that would be from /etc/php.ini if it exists. Ini_set('max_execution_time', 10) // or this way So there seem to be three ways to achieve this: I also tried the same thing and go the same result with set_time_limit(7).

Ini_set('max_execution_time') has no effect. The only references I've found to this strange decision are deep in bugtracker ( ) and in php.ini (comments for 'max_execution_time' directive). So it seems to be changed by ini_set or set_time_limit but it isn't, actually. Keep in mind that for CLI SAPI max_execution_time is hardcoded to 0. I did see the follow quote, which does seem to be accurate (see screenshot below), but having an unlimited execution time doesn't seem like a good idea. I tried to find information about where I should set the max_execution_time setting, I'm used to setting this for the version of PHP that runs with apache, but I have no idea where to set it for the version of PHP that lives in /usr/bin. I tried running ps -A (show all processes) but php is not showing up in that list, so perhaps it has timed out on it's own - but how do you manually set the time limit? I used quicksilver to launch it, so I can't press control+c at the command line.
PHP TIME LIMIT PHP.INI HOW TO
Preferably, edit them to the following values.How do you set max execution time of PHP's CLI component? I have a CLI script that has gone into a infinite loop and I'm not sure how to kill it without restarting.

Open it and find the following values, one at a time (They are located at different lines within the file).Backup a copy of this file before attempting to edit it.
PHP TIME LIMIT PHP.INI SOFTWARE
(how to do use a FTP software with WordPress ?) If you are certain that you have access to php.ini file on your server, you may proceed with the following steps. Most of the Shared Hosting Company does not allow access to this file. The php.ini file is the default PHP configuration file. To change the maximum execution time, use a text editor to modify the max_execution_time directive in your php.ini file.įor example, to set the maximum execution time to 10 seconds, use the following setting: You can control the amount of time PHP allows scripts to run by changing the max_execution_timedirective in your php.ini file. If a script runs for longer than 30 seconds, PHP stops the script and reports an error. By default, the maximum execution time for PHP scripts is set to 30 seconds.
