Linux PS Aux带有GREP检查特定PHP过程ID
我正在尝试弄清楚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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
建议
PGREP
命令,而不是ps aux
您始终获得一行的原因:
php
过程与grep'不匹配。 PHP | 123123123'
ps aux
列出grep
命令您提交,grep
命令匹配也许您是指
grep -e'php | 123123123'
匹配php
或123123123
Suggesting
pgrep
command instead ofps aux
The reason your get always one line:
php
process is not matched withgrep 'php|123123123'
ps aux
list thegrep
command you submitted and thegrep
command match itselfmaybe you meant
grep -E 'php|123123123'
to matchphp
or123123123
我遇到的解决方案要感谢上面的用户:
其中 123456 将是过程ID
The solution I've come across thanks to a user above is to do:
Where 123456 would be the process ID