PHP set timeout for script, set_time_limit not working

Posted by tehalive on Stack Overflow See other posts from Stack Overflow or by tehalive
Published on 2010-04-08T22:33:25Z Indexed on 2010/04/08 22:43 UTC
Read the original article Hit count: 368

Filed under:
|
|
|

I have a command-line PHP script that runs a wget request using each member of an array with foreach. This wget request can sometimes take a long time so I want to be able to set a timeout for killing the script if it goes past 15 seconds for example. I have PHP safemode disabled and tried set_time_limit(15) early in the script, however it continues indefinitely.

I've given up troubleshooting set_time_limit() and was trying to find other ways to kill the script after 15 seconds of execution. However, I'm not sure if it's possible to check the time a script has been running while it's in the middle of a wget request at the same time (a do while loop did not work).

Thanks for any tips!

© Stack Overflow or respective owner

Related posts about php

Related posts about linux