By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,649 Members | 696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,649 IT Pros & Developers. It's quick & easy.

-d max_execution_time

P: n/a
I'm writing a shell script under Red Hat 9 that will process some thousand
records from a database so it'll normally take several minutes. According
to manual I can override the max_execution_time directive using the -d
switch. However, that switch seems to be ignored:

#!/usr/bin/php -d max_execution_time=1 -q

<?
........
?>

No matter what value I write (0, 1, 9999...) the script stops after 30
seconds:

Maximum execution time of 30 seconds exceeded

The scripts runs as root and PHP is not using safe mode. I'm probably
missing something but I can't figure out what it is. Thank you in advance
for any clue,

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Alvaro G Vicario wrote:
I'm writing a shell script under Red Hat 9 that will process some thousand
records from a database so it'll normally take several minutes. According
to manual I can override the max_execution_time directive using the -d
switch. However, that switch seems to be ignored:

#!/usr/bin/php -d max_execution_time=1 -q

<?
.......
?>

No matter what value I write (0, 1, 9999...) the script stops after 30
seconds:

Maximum execution time of 30 seconds exceeded

The scripts runs as root and PHP is not using safe mode. I'm probably
missing something but I can't figure out what it is. Thank you in advance
for any clue,


Can't you add set_time_limit(0) to the php script?

Jul 17 '05 #2

P: n/a
Alvaro G Vicario wrote:
I'm writing a shell script under Red Hat 9 that will process some thousand
records from a database so it'll normally take several minutes. According
to manual I can override the max_execution_time directive using the -d
switch. However, that switch seems to be ignored:

#!/usr/bin/php -d max_execution_time=1 -q

<?
.......
?>

No matter what value I write (0, 1, 9999...) the script stops after 30
seconds:

Maximum execution time of 30 seconds exceeded

The scripts runs as root and PHP is not using safe mode. I'm probably
missing something but I can't figure out what it is. Thank you in advance
for any clue,

--


I guess PHP does not recognize options in the #! line
try

#!/usr/bin/php
<?php
ini_set('max_execution_time', 0);
// rest of script
?>
But php should assume max_exexcution_time = 0 when running from the
command-line. I tried

$ php -r '$x = ini_get("max_execution_time"); echo "$x\n";'
0

$ php -d max_execution_time=456 -r '$x = ini_get("max_execution_time"); echo "$x\n";'
456

--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
Jul 17 '05 #3

P: n/a
*** Pedro Graca wrote/escribió (27 Nov 2003 10:58:36 GMT):
I guess PHP does not recognize options in the #! line try
ini_set('max_execution_time', 0);
You are right, it seems PHP got confused by what you say. And I got
confused because it certainly does accept the -q switch. Now it works fine.
But php should assume max_exexcution_time = 0 when running from the
command-line.


# php -r '$x = ini_get("max_execution_time"); echo "$x\n";'
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}

I have the PHP packages bundled with Red Hat 9, it must be they are either
an older version or they are built with different options... :-?

Thank you for your help,
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #4

P: n/a
Alvaro G Vicario wrote:
But php should assume max_exexcution_time = 0 when running from the
command-line.


# php -r '$x = ini_get("max_execution_time"); echo "$x\n";'
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}

I have the PHP packages bundled with Red Hat 9, it must be they are either
an older version or they are built with different options... :-?


I think you're using the CGI SAPI. I can't test that here.

$ php -v
PHP 4.3.3 (cli) (built: Nov 19 2003 23:12:29)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

$ php -h
Usage: php [options] [-f] <file> [args...]
php [options] -r <code> [args...]
....
-r <code> Run PHP <code> without using script tags <?..?>
-s Display colour syntax highlighted source.
-v Version number
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
Jul 17 '05 #5

P: n/a
*** Pedro Graca wrote/escribió (27 Nov 2003 11:40:06 GMT):
I think you're using the CGI SAPI. I can't test that here.

$ php -v
PHP 4.3.3 (cli) (built: Nov 19 2003 23:12:29)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
# php -v
4.2.2


$ php -h
Usage: php [options] [-f] <file> [args...]
php [options] -r <code> [args...]
...
-r <code> Run PHP <code> without using script tags <?..?>
-s Display colour syntax highlighted source.
-v Version number


# php -h
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-w Display source with stripped comments and whitespace.
-f <file> Parse <file>. Implies `-q'
-v Version number
-C Do not chdir to the script's directory
-c <path> Look for php.ini file in this directory
-a Run interactively
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-z <file> Load Zend extension <file>.
-l Syntax check only (lint)
-m Show compiled in modules
-i PHP information
-h This help
The funny thing is that I can't find any "cli" packet in Red Hat
repositories. Never mind, it works so it's fine :)

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #6

P: n/a
Alvaro G Vicario wrote:
The funny thing is that I can't find any "cli" packet in Red Hat
repositories. Never mind, it works so it's fine :)


With Debian I did:

# apt-get install php4-cgi

Maybe the package name is cgi also on Red-Hat, if you want to install
it.
Anyway, glad you have it working
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
Jul 17 '05 #7

P: 2
try using the set_time_limit(int seconds) function



I'm writing a shell script under Red Hat 9 that will process some thousand
records from a database so it'll normally take several minutes. According
to manual I can override the max_execution_time directive using the -d
switch. However, that switch seems to be ignored:

#!/usr/bin/php -d max_execution_time=1 -q

<?
........
?>

No matter what value I write (0, 1, 9999...) the script stops after 30
seconds:

Maximum execution time of 30 seconds exceeded

The scripts runs as root and PHP is not using safe mode. I'm probably
missing something but I can't figure out what it is. Thank you in advance
for any clue,

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jun 30 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.