Are PHP scripts run using the "php" command affected by the timeout limit? I plan to schedule php scripts using cron.
Yes, but you can set an unlimited timeout by adding this to the top of your script:
Some systems, such as Ubuntu, actually already start with separate CLI and Apache configurations in
The relevant command in the ini file is:
max_execution_time = 30 ; Maximum execution time of each script, in seconds
However, if you are unable to modify the php.ini for whatever reason, you can create a new php.ini with configuration settings favourable to the command-line, and point to the file like so:
php -c /path/to/ini/php.ini -f script.php
Or, you can use Cailin's solution, and set the time limit at the top of the file - but if you are running on a server with PHP 'safe mode' enabled, then you will have to use your own ini file.
Depends. If your php binary is the PHP CLI interface, the default
max_execution_time is zero (meaning there is no limit).
On the other hand, if it's the older-style CGI binary, you will be affected by the
max_execution_time limit, and you'll need to call
set_time_limit to get rid of it (assuming you're not in the dreaded PHP safe mode).