Current time: 04-23-2014, 03:47 AM Hello There, Guest! (LoginRegister)

Post Reply 
PHP: set_time_limit() has no effect
06-23-2007, 05:54 AM
Post: #1
PHP: set_time_limit() has no effect
I'm trying to limit the maximum execution time of one of my PHP scripts using set_time_limit(1), but it does not seem to have any effect.

PHP's manual states the following:

"[The set_time_limit() function] has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini."

Does Dreamhost have PHP running in safe mode? I'm on Fiji. Am I able to have a php.ini file for myself to edit? Is there any other way to limit my script's maximum execution time?

Any assistance in this matter would be greatly appreciated -- thanks in advance Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 06:03 AM
Post: #2
PHP: set_time_limit() has no effect
You can't set PHP settings without changing the PHP.ini file on DreamHost, and thus this wiki article comes in handy. Let us know if you need any help with it Wink

--------------------------
Chips N Cheese - Custom PHP installs and the like!
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 06:33 AM
Post: #3
PHP: set_time_limit() has no effect
Thanks for the link Smile

However, I only want to change the max_execution_time setting for one script, not for everything.

Am I out of luck?

...or, if I end up having php.ini and php.cgi in my home directory, would set_time_limit() work?
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 06:47 AM
Post: #4
PHP: set_time_limit() has no effect
Well with the php.ini, in the case of that wiki link, you're using DreamHost's own setup - so you wouldn't actually be changing anything other than the options you want, which is quite cool! And yes, you can change *just* the time limit, which would be this setting from within the php.ini file:

Quote:max_execution_time = 120

--------------------------
Chips N Cheese - Custom PHP installs and the like!
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 06:53 AM
Post: #5
PHP: set_time_limit() has no effect
Ideally I would like to just call the set_time_limit() function within my single script to change the max_execution_time setting for one script.

I'm wanting to to change the max time to 1 second, and this probably wouldn't be a good thing for my other scripts, which is why I'm wary of editing php.ini to do this.

Would copying over Dreamhost's php.ini to my home dir and editing my .htaccess file (as stated in the Wiki page) allow set_time_limit() to work when called in my script, or would that still have no effect?
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 07:38 AM
Post: #6
PHP: set_time_limit() has no effect
Ahhh, well unfortunately this method will affect all of your scripts, and I'm unaware of how to avoid that. There's really no better solution though that I'm aware of for your situation, other than to use the Custom PHP.ini method as explained in the wiki article.

Quote:Would copying over Dreamhost's php.ini to my home dir and editing my .htaccess file (as stated in the Wiki page) allow set_time_limit() to work when called in my script, or would that still have no effect?
I've already explained this - Yes, it will work just fine.

--------------------------
Chips N Cheese - Custom PHP installs and the like!
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 07:41 AM
Post: #7
PHP: set_time_limit() has no effect
Ah, I must've misinterpreted your post.

Thanks for your help -- I'll give it a try Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2007, 11:23 AM
Post: #8
PHP: set_time_limit() has no effect
One possible work around to have the custom php.ini setting only effect the single script is to run that script from its own subdomain (which can have it's *own* php setup). Wink

--rlparker
Find all posts by this user
Quote this message in a reply
06-23-2007, 08:09 PM
Post: #9
PHP: set_time_limit() has no effect
Since you're declaring the PHP to run as your custom setup in .htaccess, couldn't you put the script in a separate directory with an .htaccess telling all PHP scripts in that directory only to run with the custom php.ini setup. That way only that directory is affected.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2007, 01:22 AM
Post: #10
PHP: set_time_limit() has no effect
I don't see any reason why not (I only mentioned *one* workaround - yours may well be better)! Wink

--rlparker
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: