linux下php文件进行后台运行的3种方法:

三种解决办法:

  1. nohup
    [root@iZj6cfzkpp77ljw6grkiypZ notify2.aowhy.com]# nohup php serve.php &

2。setsid
[root@iZj6cfzkpp77ljw6grkiypZ notify2.aowhy.com]#setsid ping www.pythontab.com
[root@iZj6cfzkpp77ljw6grkiypZ notify2.aowhy.com]# ps -ef |grep www.pythontab.com

3。& subshell
[root@iZj6cfzkpp77ljw6grkiypZ notify2.aowhy.com]# (php serve.php &)
[root@iZj6cfzkpp77ljw6grkiypZ notify2.aowhy.com]# ps -ef|grep serve.php
root 10318 9153 0 10:19 pts/1 00:00:00 php serve.php
root 10319 10318 0 10:19 pts/1 00:00:00 php serve.php
root 10321 10319 0 10:19 pts/1 00:00:00 php serve.php
root 10324 9153 0 10:19 pts/1 00:00:00 grep --color=auto serve.php
[root@pythontab ~]#

你可能感兴趣的:(服务器)