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
kill $(pgrep irssi)
killall -v irssi
pkill irssi
kill `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.
kill $(pgrep irssi)
killall -v irssi
pkill irssi
kill `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.
本文介绍了几种通过进程名称来终止进程的方法,适用于不知道进程ID的情况。包括使用pgrep、killall及pkill等命令,并展示了如何在shell脚本中实现这些操作。
1万+

被折叠的 条评论
为什么被折叠?



