Php – way to use shell_exec without waiting for the command to complete

PHPshell

I have a process intensive task that I would like to run in the background.

The user clicks on a page, the PHP script runs, and finally, based on some conditions, if required, then it has to run a shell script, E.G.:

shell_exec('php measurePerformance.php 47 844 email@yahoo.com');

Currently I use shell_exec, but this requires the script to wait for an output. Is there any way to execute the command I want without waiting for it to complete?

Best Answer

How about adding.

"> /dev/null 2>/dev/null &"

shell_exec('php measurePerformance.php 47 844 email@yahoo.com > /dev/null 2>/dev/null &');

Note this also gets rid of the stdio and stderr.

Related Topic