I'm aware that we can run background process with the following:
exec("doTask.php $arg1 $arg2 $arg3 >/dev/null 2>&1 &");
(Taken from: Run PHP Task Asynchronously)
However I have a script that depends on the status of the first execution. Example:
mongoexport ... | awk ... > my.csv && zip myzip my.csv
The CSV file must exists before it can zip.
Update: filename and a few query conditions are user submitted values.
So I have something like:
exec("mongoexport ... | awk ... > my.csv && zip myzip my.csv > /dev/null 2>&1 &);
But that doesn't work. PHP hangs there waiting for the script to finish running.
I tried
exec("mongoexport ... | awk ... > my.csv &);
That works.
So is &&
the reason it doesn't run in background?
How can I make the example run in background?