Execute a command in the background

Description PHP

This function allows you to execute a command in the system without having to wait for it to finish.

The Code Download

  1. <?php
  2. function execInBackground($cmd) {
  3.     if (substr(php_uname(), 0, 7) == "Windows"){
  4.         pclose(popen("start /B ". $cmd, "r"));
  5.     }
  6.     else {
  7.         exec($cmd . " > /dev/null &");  
  8.     }
  9. }
  10. ?>

Credits

Added by JC on 12th May 2010

Comments

There are no comments about this snippet.

Post Comment Github Markdown Supported

You must be logged in to post a comment.

Login here to post a comment