For example, a file like the following test.php
/dev/null 2>&1 & echo $!");?>
Execute PHP test.php under terminal to leave the process in the background
However, when accessing test.php through a browser, you cannot leave a process in the background
Speculation may be the Web process aborted at the same time sleep also to abort, want to keep, what good solution?
Reply content:
For example, a file like the following test.php
/dev/null 2>&1 & echo $!");?>
Execute PHP test.php under terminal to leave the process in the background
However, when accessing test.php through a browser, you cannot leave a process in the background
Speculation may be the Web process aborted at the same time sleep also to abort, want to keep, what good solution?
Use the swoole extension to write a PHP socket server that runs as a daemon.
Try PHP for this function Ignore_user_abort specific usage reference http://cn2.php.net/manual/en/function.ignore-user-abort.php
It should all be here:
http://www.php.net/manual/en/features.connection-handling.php
Basically:
-
By default, the script aborts if the remote client disconnects. Change the default setting by Ignore_user_abort (php.ini), Ignore_user_abort (Apache httpd.conf), or by calling the Ignore_user_abort () function;
-
The default script has a maximum run time of 30 seconds. Can be modified by Max_execution_time (php.ini), Max_execution_time (Apache httpd.conf) or by calling the Set_time_limit () function.