I am having a hard time identifying the solution to my problem. Here is a simple explanation.
Using the following code, I am able to launch a script using the shell_exec() function :
shell_exec("nohup /usr/bin/php /home/script.php > /dev/null & echo $!");
This works perfectly.
But when I launch the PHP script using the shell_exec() function and assigning the returned PID using the following code, the script process is not launched and no action is completed (although the $pid is echoed correctly) :
$pid = shell_exec("nohup /usr/bin/php /home/script.php > /dev/null & echo $!");
echo 'Process ID : ' . $pid;
How can I retrieve the PID and execute the process for this "script.php" ?
nohup /usr/bin/php /home/script.php > /dev/null & echo $!directly on the command line to observe the results?shell_execreturns whatever the output of the program run is. - Devin H.echo $!will return the process PID and this is what I need. Running the shell_exec() function works if no variable is assigned from the return. Is there a way to echo PID from "script.php" ? (Answer to your question : I have no direct access to shell for the moment.) - wlarcheveque