简体   繁体   English

如何停止在另一个页面中执行php脚本?

[英]How to stop the execution of a php script in another page?

I've just learned how to setup and start a web-socket server using Ratchet. 我刚刚学习了如何使用Ratchet设置和启动Web套接字服务器。

I've learned how to start the script using a command from the terminal and the script keeps running forever. 我已经学会了如何使用终端上的命令来启动脚本,并且脚本可以永远运行。

What I want to know now, is how can I start and stop that script (the web-socket server) using php code, not terminal, So that I can have a button to start and stop the web-socket server whenever I want ? 我现在想知道的是如何使用php代码而不是终端来启动和停止该脚本(Web套接字服务器),这样我就可以有一个按钮来随时启动和停止Web套接字服务器?

This question might seem naive, but I don't have a clue on how to this, I am new to Ratchet and web-socket. 这个问题似乎很幼稚,但是我对如何做到这一点一无所知,因为我对Ratchet和网络套接字是陌生的。

If you know the pid, then just use command, 如果您知道pid,则只需使用命令,

exec("kill -9 $pid");

Otherwise, you can use 否则,您可以使用

exec("pkill $progname"); //To kill a any command with name as $progname

Please refer to this for more such options. 有关更多此类选项,请参考此内容。

How to kill all processes with a given partial name? 如何使用给定的部分名称杀死所有进程?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM