How do you set max execution time of PHP's CLI component?

Posted by cwd on Server Fault See other posts from Server Fault or by cwd
Published on 2011-06-23T13:19:54Z Indexed on 2011/06/23 16:24 UTC
Read the original article Hit count: 246

Filed under:
|

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. I used quicksilver to launch it, so I can't press control+c at the command line. 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 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 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.

Keep in mind that for CLI SAPI max_execution_time is hardcoded to 0. So it seems to be changed by ini_set or set_time_limit but it isn't, actually. The only references I've found to this strange decision are deep in bugtracker (http://bugs.php.net/37306) and in php.ini (comments for 'max_execution_time' directive). (via http://php.net/manual/en/function.set-time-limit.php)

ini_set('max_execution_time') has no effect. I also tried the same thing and go the same result with set_time_limit(7).

© Server Fault or respective owner

Related posts about php

Related posts about command-line