note 86329 modified in function.exec by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Oct 2008 15:05:32 +0000 |
| Subject: | note 86329 modified in function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145320@lists.php.net to get a copy of this message | ||
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.
--was--
I combined several efforts in this topic into one function:
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