There are several ways to achieve this:
Starting a background process with & :
exec('nohup ./loop.php > loop.out 2>&1 &');
Using pcntl_fork and starting your process from a child:
$pid = pcntl_fork(); switch ($pid){ case -1: die('Fork failed'); break; case 0: exec('nohup ./loop.php > loop.out'); exit(); default: break; } echo "I'm not really a superman, just a parent process';
There are more ways to do this, just have a look at the documentation and PHP questions in php here ...
source share