Snippets v2

Languages
My Snippets

Execute a command in the background Login or Register to Bookmark this snippet

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 Contact JC

Added by JC on 12th May, 2010

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment