I am trying to run bgprocess.php in background and want to save output in backgroundOutput.php
exec("php bgprocess.php > backgroundOutput.php 2>&1 & echo $!", $commandOutput);
But its not showing any error on $commandOurput and not run bgprocess.php as well.
Its works : exec("php bgprocess.php", $commandOutput);
and also works from terminal command line.
tried following possible way to solve issue by reference :
nohup bgprocess.php > backgroundOutput.php 2>&1 & echo $!