Linux PS Aux带有GREP检查特定PHP过程ID

发布于 2025-01-24 09:20:31 字数 381 浏览 2 评论 0原文

我正在尝试弄清楚PHP进程是否正在运行ps aux命令并将GREP传递给它,例如:

我需要它返回并告诉我是否在PHP上运行的过程ID,但是每当我尝试以下操作时,我似乎总是会得到结果,结果在结束时添加1234,我缺少什么?

ps aux | grep 'php|1234'

I'm trying to figure out whether a PHP process is running or not using the ps aux command and passing grep to it, for instance:

I need it to return and tell me whether a process ID on php is running or not but whenever I try the following I always seem to get a result where the result is appending 1234 at the end, what am I missing?

ps aux | grep 'php|1234'

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我们只是彼此的过ke 2025-01-31 09:20:31

建议PGREP命令,而不是ps aux

pgrep -af "php"

您始终获得一行的原因:

  1. php过程与grep'不匹配。 PHP | 123123123'

  2. ps aux列出grep命令您提交,grep命令匹配

  3. 也许您是指grep -e'php | 123123123'匹配php123123123

Suggesting pgrep command instead of ps aux

pgrep -af "php"

The reason your get always one line:

  1. php process is not matched with grep 'php|123123123'

  2. ps aux list the grep command you submitted and the grep command match itself

  3. maybe you meant grep -E 'php|123123123' to match php or 123123123

山川志 2025-01-31 09:20:31

我遇到的解决方案要感谢上面的用户:

ps aux | grep '123456' | grep 'grep' -v

其中 123456 将是过程ID

The solution I've come across thanks to a user above is to do:

ps aux | grep '123456' | grep 'grep' -v

Where 123456 would be the process ID

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文