title: PHP set timeout for script with system call, set_time_limit not working
body: <p>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. <strong>Update:</strong> Thanks to Dor for pointing out this is because set_time_limit() does not respect system() calls.</p>
  
  <p>So I 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). Maybe fork a process with a timer and set it to kill the parent after a set amount of time?</p>
  
  <p>Thanks for any tips!</p>
  
  <p><strong>Update:</strong>
  Below is my relevant code. $url is passed from the command-line and is an array of multiple URLs (sorry for not posting this initially):</p>
  
  <pre><code>foreach( $url as $key =&gt; $value){
      $wget = "wget -r -H -nd -l 999 $value";
      system($wget);
      }
  </code></pre>