小知識:閱讀約2分鍾
第一種方法:kill [信號代碼] 進程ID
注:信號代碼可以省略;我們常用的信號代碼是 -9 ,表示強制終止。
對於僵屍進程,可以用kill -9 來強制終止退出。
kill 的應用,是和ps 或pgrep 命令結合在一起使用的。如下:
1 [root@-linux-byx ~]# ps -ef|grep magic_Linux 2 root 13020 1 1 1月16 ? 00:33:35 ./magic_Linux01 3 root 22761 1 1 01:27 ? 00:06:35 ./magic_Linux02 4 root 25279 1 0 1月16 ? 00:16:48 ./magic_Linux03 5 root 27694 1 0 1月16 ? 00:16:48 ./magic_Linux04
kill 命令實例: 用kill 殺死 進程 magic_Linux02
[root@-linux-byx ~]# kill -9 22761
與kill命令不同的是,killall 命令可以根據進程名稱來殺死進程。kill 命令 則先需要找到進程的id。
第二種方法:killall 通過程序的名字,直接殺死所有進程
killall 也和ps或pgrep 結合使用,比較方便。如下:
1 [root@-linux-byx ~]# pgrep -l magic_Linux 2 13020 magic_Linux01 3 22761 magic_Linux02 4 25279 magic_Linux03 5 27694 magic_Linux04
killall 命令實例: 用killall 殺死 進程 magic_Linux02
[root@-linux-byx ~]# killall magic_Linux02
希望可以幫助到你。
by不言謝。