Monday, February 9, 2015

running multiple PHP process in background

Method 1:

<?php
exec('php fileName.php > /dev/null 2>&1 &');
?>

Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

Method 2:

pcntl_fork()

1 comment:

Unknown said...

pcntl_fork is also an option to solve this solution.