note 86329 modified in function.exec by danbrown
| From: | danbrown@php.net | Date: | Thu, 17 Jan 2013 15:38:54 +0000 |
| Subject: | note 86329 modified in function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193173@lists.php.net to get a copy of this message | ||
This will execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on
both Windows and Unix.
<?php
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
?>
--was--
I combined several efforts in this topic into one function:
<?php
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
?>
This will execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on
both Windows and Unix.
http://php.net/manual/en/function.exec.php