如何保持持久的PHP脚本运行? [英] How to keep a persistent PHP script running?

查看:103
本文介绍了如何保持持久的PHP脚本运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有监听传入套接字请求PHP脚本,等我需要这个脚本在服务器上运行持续(它的无限循环中运行)。

我怎么能启动和管理这个过程?我试着刚开始它通过SSH /腻子,但只要SSH连接超时脚本死亡。


解决方案

  myscript.php&安培;

这将运行scriptin背景

您可以检查

 的ps aux | grep的myscript.php

由于帕特里克在下面的评论提到,没有最大的执行时间为PHP脚本运行命令行。 myscript.php 将无限期地运行。

I have a PHP script that listens for incoming socket requests, etc. I need this script to be continually running (it runs within an infinite loop) on the server.

How can I initiate and manage this process? I tried just starting it up through SSH/putty but as soon as the SSH connection times out the script dies.

解决方案

myscript.php &

This will run the scriptin the background

you can check it with

ps aux | grep myscript.php

As Patrick has mentioned in the comments below, there is no maximum execution time for PHP scripts run from command line. myscript.php will run indefinitely.

这篇关于如何保持持久的PHP脚本运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆