tags:

views:

55

answers:

6

Hi guys, time for another brain teaser of something I guess is quite rare.

Is there a hard limit in PHP? Or in Apache? I had a script running last night which lasted around 20 hours. Then it just stopped, mid script on a random line with no errors that I could find.

set_time_limit(0); was set in the script but I'm starting to wonder if there is another limit somewhere else for around 20 hours...

any ideas?

Many thanks in advance.

edit: this is run as a wget.

edit2: I am going to look at the memory issue and get back to you, thanks for the help thus far!

edit3: Oh I should point out this script is gathering data and storing it in an array, the longer it is running the more it is storing so yeah, I'm kinda palm facing on the "used up all the memory" answers here...

SOLUTION: Setting a larger memory for the operation fixed this. Thank you everyone.

+1  A: 

problably the php-cli just crashed or your server rebooted. i dont think php is ment to be executed that long

Christian Smorra
The fact there were multiple scripts running and the other scripts continued (they were shorter run at different points) show to me that the server didn't crash but you might be right about php failing after a certain time.
Dorjan
maybe you should run the script from command line the instead via apache also its possible that the memory consumption for that script was to high, you could increase that with ini_set('memory_limit', '128M');
Christian Smorra
Thanks Christian, I'll look at the current setting now
Dorjan
Is there a max for memory usage? Or is it as high as your system allows?
Dorjan
its defined in you php.ini, i dont think there is a max, ive had faulty scripts with infinite loops use upto 256 mb :P
Christian Smorra
ini_set('memory_limit', '512M');lets give that a try
Dorjan
The memory limit has fixed the issue!
Dorjan
im happy i could help :)
Christian Smorra
+1  A: 

i had a script that ran for several months without a problem. i just had to kill the process to terminate the script. so there's no limit if you have set_time_limit(0); in your code. have you looked at the system and debug logs of your operating system? that may provide further clues why php or apache crashed.

stillstanding
This is helpful because now I know PHP can run this long
Dorjan
+2  A: 

Perhaps PHP runs out of memory after a while.

zwip
I will try too see if this is the case, thanks!
Dorjan
A: 

since you used wget, i am assuming here it is running under apache. maybe it is apache that has a limit on a running script and not your php application.

you could test this by running the application from the cli version

bumperbox
Apache Timeout is the TimeOut Directive in httpd.conf. If no value is specified, then the default is 300 seconds http://httpd.apache.org/docs/2.0/mod/core.html#timeout
Mark Baker
Unfortunately I've not got the time to get the application running rom cli as the paths seem to be different for the includes and the like (I can't remember why I had to move away from it now but I remember trying the cli way first and ending up with wget although I didn't want too)
Dorjan
+1  A: 

as stillstanding said, check the apache logs, /var/log/error.log, or in windows the "events".

a1337q
imho there must be an error in your script, maybe you violated the php memory limit?
a1337q
the php memory limit might be the more likely suspect! I didn't think of that, thanks.
Dorjan
Checking the logs now also
Dorjan
A: 
srinivas
the time limit is stated as being disabled in the original post.
Dorjan