There are a number of ways to kill a process if you know the name of the process. Here’s a couple different ways you can accomplish this. We are going to assume that the process we are trying to kill is named irssi
如果您知道進程的名稱,則有多種方法可以殺死該進程。 您可以通過以下兩種不同的方法來完成此操作。 我們將假設我們要殺死的進程名為irssi
kill $(pgrep irssi)
殺死$(pgrep irssi)
killall -v irssi
Killall -v irssi
pkill irssi
菲爾·伊爾西
kill `ps -ef | grep irssi | grep -v grep | awk ‘{print $2}’`
殺死`ps -ef | grep irssi | grep -v grep | awk'{print $ 2}'`
These techniques can be useful in shell scripts, where you wouldn’t know the process ID and would need to restart or kill a process.
這些技術在Shell腳本中非常有用,因為您不知道進程ID,因此需要重新啟動或終止進程。
翻譯自: https://www.howtogeek.com/howto/ubuntu/kill-a-process-by-process-name-from-ubuntu-command-line/