将 php 脚本作为守护进程运行

编程入门 行业动态 更新时间:2024-10-06 01:42:39
本文介绍了将 php 脚本作为守护进程运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要运行一个 php 脚本作为守护进程(等待指令并做一些事情).cron 作业不会为我做这件事,因为一旦指令到达就需要采取行动.我知道由于内存管理问题,PHP 并不是守护进程的最佳选择,但由于各种原因,我必须在这种情况下使用 PHP.我遇到了 libslack 的一个名为 Daemon(libslack/daemon)的工具,它似乎对我有帮助管理守护进程,但在过去 5 年中没有任何更新,所以我想知道您是否知道其他一些适合我的情况的替代方案.任何信息将不胜感激.

I need to run a php script as daemon process (wait for instructions and do stuff). cron job will not do it for me because actions need to be taken as soon as instruction arrives. I know PHP is not really the best option for daemon processes due to memory management issues, but due to various reasons I have to use PHP in this case. I came across a tool by libslack called Daemon (libslack/daemon) it seems to help me manage daemon processes, but there hasn't been any updates in the last 5 years, so I wonder if you know some other alternatives suitable for my case. Any information will be really appreciated.

推荐答案

您可以使用

nohup php myscript.php &

& 将您的进程置于后台.

the & puts your process in the background.

是的,有一些缺点,但无法控制?那是错误的.一个简单的 kill processid 将停止它.它仍然是最好和最简单的解决方案.

Yes, there are some drawbacks, but not possible to control? That's just wrong. A simple kill processid will stop it. And it's still the best and simplest solution.

更多推荐

将 php 脚本作为守护进程运行

本文发布于:2023-11-23 22:00:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   进程   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!