简体   繁体   中英

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. 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.

Also, it doesn't kill the process, just returns the process ID of it. 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 supervisord

Or

kill $(pidof supervisord)

Pidof looks at the process list in the following way

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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