Answer the question
In order to leave comments, you need to log in
How to properly start php daemon from php script?
I run
shell_exec("php time.php");
but the current script hangs. It is necessary to start somehow so that shell_exec does not wait, but immediately returns control to the script
Answer the question
In order to leave comments, you need to log in
public function run() {
$set = array(
'command' => 'work',
);
$this->demon = $this->setParam($set);
chdir($this->demon['dir']);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
/* Система Windows */
pclose(popen('start /B cmd /C "php '. $this->demon['name'] .' >NUL 2>NUL"', 'r'));
} else {
/* Система *nix */
$command = 'php -f ' . $this->demon['name'] . ' > /dev/null 2>&1 &';
exec($command);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question