如何找出进程在 Linux 中运行的 PHP 脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9468332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:52:10  来源:igfitidea点击:

How can I find out which PHP script a process is running in Linux?

phplinuxapacheprocess

提问by Mike

Running Linux, Apache, PHP 5.3 with FastCGI Handler.

使用 FastCGI 处理程序运行 Linux、Apache、PHP 5.3。

Is it possible to find out the script that is being executed for a linux process? I've been searching on google and haven't been able to find anything useful.

是否可以找出正在为 linux 进程执行的脚本?我一直在谷歌上搜索,但没有找到任何有用的东西。

回答by Luca Davanzo

Maybe you can try this!

也许你可以试试这个!

ps ax | grep *.php

回答by hohner

In one SSH window:

在一个 SSH 窗口中:

telnet localhost 80

In another, find out the port number:

在另一个中,找出端口号:

lsof -p `pidof telnet`

Then, to find out the process:

然后,找出过程:

netstat -nap | grep {port}

And finally:

最后:

strace -o /tmp/output -f -r -s4096 -p {PID}

Will show you every processwhich runs when you make a httpd connection to the server in order. If you search through this list you'll find your PHP script.

会告诉你每一个过程,当您在顺序的httpd服务器的连接它运行。如果您搜索此列表,您将找到您的 PHP 脚本。

回答by Qian

pstree | grep php
ps aux | grep php
ps xuww | grep php
...

回答by kenorb

You can use pgrepfor that, e.g.

你可以使用pgrep它,例如

pgrep -l php

or:

或者:

pgrep php && echo PHP script is running || echo PHP script is NOT running

回答by Andrew

Just use:

只需使用:

ps aux | grep php

Shows you php scripts running with their paths.

向您展示使用其路径运行的 php 脚本。