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

编程入门 行业动态 更新时间:2024-10-05 23:24:18
本文介绍了将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:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   进程   PHP

发布评论

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

>www.elefans.com

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