Linux bash pidof command wont work
-
03-07-2021 - |
Domanda
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
Soluzione
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)
Altri suggerimenti
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
Try
pgrep -f "supervisord"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow