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/