title: nohup: run PHP process in background
body: <p>i try to run php processes in background and start this from an php file. </p>
  
  <p>Some informations: PHP Version 5.2.17, php safe_mode is off, linux system. I start the process with exec, tried already shell_exec. I set all files to 0755, 0777.</p>
  
  <pre><code>$pid = exec("nohup $cmd &gt; /dev/null 2&gt; /dev/null &amp; echo $!");
  </code></pre>
  
  <p>If i print this statement, i get this and the pid is okay:</p>
  
  <pre><code>nohup /usr/local/bin/php5 /.../../file.php &gt; /dev/null 2&gt; /dev/null &amp; echo $!
  </code></pre>
  
  <p>If i look for processes under ssh with</p>
  
  <pre><code>top
  </code></pre>
  
  <p>i see my php5 process with the correct pid. user is root</p>
  
  <pre><code>  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                      
   3533 xxxxxxxx  20   0 21356 8868 4580 S    0  0.4   0:00.13 php5                                                                                          
   3536 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5                                                                                          
   3539 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5                                                                                          
   3542 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5                                                                                          
   3545 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5                                                                                          
   3548 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5                                                                                          
   3551 xxxxxxxx  20   0 20836 8260 4428 S    0  0.4   0:00.09 php5    
  </code></pre>
  
  <p>if i start the process manual top looks like this:</p>
  
  <pre><code>PID  USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 
  8141 xxxxxxxx  22   2 24048 9.9m 5344 S   10  0.5   0:00.31 php5 
  </code></pre>
  
  <p><strong>The problem:</strong> 
  it seems like nothing happens.To debug a little bit i wrote a output in the file</p>
  
  <pre><code>ob_start();
  echo "STARTING...";
  writeLog(ob_get_contents());
  //...
  function writeLog($info){
      $handle = fopen("file.log", "a+");
      fwrite($handle, $info);
      fclose($handle);
  } 
  exit;
  </code></pre>
  
  <p>No logs in my file. If I start this file in my browser, it processes correctly and get my file.log with the "debugging" information.</p>
  
  <p>Why this is working in browser and not on exec/shell_exec command??! i have exactly these php processes with correct pid, but no result. </p>
  
  <p>Thanks a lot for help!</p>