Home  >  Article  >  Backend Development  >  linux后台运行php脚本

linux后台运行php脚本

WBOY
WBOYOriginal
2016-06-06 20:10:351102browse

现有A、B两台服务器, 其中B服务器上运行着8888端口的软件服务,A服务器上现在命令行使用
-> php a.php执行这这脚本,实时监听B服务器的8888端口,如果有设备向B服务器的服务软件发布消息,a.php就会接收到,然后进行处理。

现在的问题是如果关闭本地连接的shell,脚本就会停止运行,怎样能让a.php 一直在服务器上后台执行呢?

回复内容:

现有A、B两台服务器, 其中B服务器上运行着8888端口的软件服务,A服务器上现在命令行使用
-> php a.php执行这这脚本,实时监听B服务器的8888端口,如果有设备向B服务器的服务软件发布消息,a.php就会接收到,然后进行处理。

现在的问题是如果关闭本地连接的shell,脚本就会停止运行,怎样能让a.php 一直在服务器上后台执行呢?

除了nohup,还可以选择supervisor、screen等

另外supervisor应该是最适合的,他除了监控进程状态还可以在异常退出时自动重启!

nohup php a.php &
http://www.cnblogs.com/kapok/archive/2005/11/23/283108.html

nohup命令

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn