Created
May 26, 2015 01:25
-
-
Save mrofi/b89bd972d239c3bc3a08 to your computer and use it in GitHub Desktop.
This will execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on both Windows and Unix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function execInBackground($cmd) { | |
if (substr(php_uname(), 0, 7) == "Windows"){ | |
pclose(popen("start /B ". $cmd, "r")); | |
} | |
else { | |
exec($cmd . " > /dev/null &"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment