[nycphp-talk] Timing out in php batch

Eric Gewirtz egewirtz at
Wed Jun 15 14:24:17 EDT 2005

Hi Dan - 

Can you point me to what you were reading?

Also, since we are running in batch we are running php (cli)

-bash-2.05b$ php -v
PHP 4.3.10 (cli) (built: Feb  3 2005 23:39:53)

When run in batch, the following returns "0" as documented to be
unlimited execution time

Yet, we are still timing out only when the machine is bogged down - when
run standalone the process always finishes in about 50 minutes of run

Here is what I see in the manual -
There are certain php.ini directives which are overridden by the CLI
SAPI because they do not make sense in shell environments: 

Table 43-1. Overridden php.ini directives

Directive CLI SAPI default value Comment 
html_errors FALSE It can be quite hard to read the error message in your
shell when it's cluttered with all those meaningless HTML tags,
therefore this directive defaults to FALSE.  
implicit_flush TRUE It is desired that any output coming from print(),
echo() and friends is immediately written to the output and not cached
in any buffer. You still can use output buffering if you want to defer
or manipulate standard output.  
max_execution_time 0 (unlimited) Due to endless possibilities of using
PHP in shell environments, the maximum execution time has been set to
unlimited. Whereas applications written for the web are often executed
very quickly, shell application tend to have a much longer execution
register_argc_argv TRUE Because this setting is TRUE you will always
have access to argc (number of arguments passed to the application) and
argv (array of the actual arguments) in the CLI SAPI. 

As of PHP 4.3.0, the PHP variables $argc and $argv are registered and
filled in with the appropriate values when using the CLI SAPI. Prior to
this version, the creation of these variables behaved as they do in CGI
and MODULE versions which requires the PHP directive register_globals to
be on. Regardless of version or register_globals setting, you can always
go through either $_SERVER or $HTTP_SERVER_VARS. Example:

Note: These directives cannot be initialized with another value from the
configuration file php.ini or a custom one (if specified). This is a
limitation because those default values are applied after all
configuration files have been parsed. However, their value can be
changed during runtime (which does not make sense for all of those
directives, e.g. register_argc_argv). 

Eric Gewirtz
Phone - 845-729-7800
Fax     - 845-279-5502
egewirtz at

>-----Original Message-----
>From: talk-bounces at
[mailto:talk-bounces at] On
>Behalf Of Dan Cech
>Sent: Wednesday, June 15, 2005 11:48 AM
>To: NYPHP Talk
>Subject: Re: [nycphp-talk] Timing out in php batch
>Maggie Cassidy wrote:
>> Isn't the set_time_limit/setting the max_execution_time irrelevant in
>> mode/command line script?
>According to the manual page I referenced earlier, the
>max_execution_time setting does not take into account time spent
>for 'system calls using system(), stream operations, database queries,
>etc.'.  As far as I am aware the timeout will still be in effect for
>script itself, regardless of whether it is run from the command line,
>cgi or apache module.
>New York PHP Talk Mailing List
>AMP Technology
>Supporting Apache, MySQL and PHP

More information about the talk mailing list