简体   繁体   English

Linux bash pidof 命令不起作用

[英]Linux bash pidof command wont work

This is a minor error that I can't figure out.这是一个我无法弄清楚的小错误。 When I enter the pidof command to shut down a process, the command line just executes pidof and goes to the next line and nothing happens.当我输入pidof命令关闭进程时,命令行只执行 pidof 并转到下一行,什么也没有发生。 No error message no nothing.没有错误信息没有什么。

Example:例子:

pidof supervisord

That's the expected behavior of pidof when it doesn't find any processes by that name.当 pidof 找不到任何具有该名称的进程时,这是 pidof 的预期行为。

Also, it doesn't kill the process, just returns the process ID of it.此外,它不会终止进程,只是返回它的进程 ID。 You want to use "killall" to actually kill a process, or a combination of "pidof" to get the PID and "kill" to kill that PID.您想使用“killall”来实际终止一个进程,或者使用“pidof”来获取PID和“kill”来终止该PID。

killall supervisord

Or要么

kill $(pidof supervisord)

Pidof looks at the process list in the following way pidof 通过以下方式查看进程列表

root       526  0.9  0.0  56556 11788 ?        Ss   Sep19  89:39 /usr/bin/python 
/usr/bin/supervisord

So,所以,

 # pidof python  
 526

尝试

pgrep -f "supervisord"

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

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