Linux进程管理命令-kill

3,966次阅读
没有评论

共计 2782 个字符,预计需要花费 7 分钟才能阅读完成。

提醒:本文最后更新于2018-09-07 01:52,文中所关联的信息可能已发生改变,请知悉!

[v_act]格式:kill -l [signal]
    -l:显示当前系统可用信号[/v_act]

[root@localhost ~]# kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX

常用信号:
    1) SIGHUP: 无须关闭进程而让其重读配置文件;PID不变
    2) SIGINT: 中断正在运行的进程;相当于Ctrl+c;
    9) SIGKILL: 杀死正在运行的进程;直接终止进程;谨慎
    15) SIGTERM:终止正在运行的进程;进程终止前允许可保存数据;默认缺省信号
指定信号的方法:
    (1) 信号的数字标识;1, 2, 9
    (2) 信号完整名称;SIGHUP
    (3) 信号的简写名称;HUP
[v_act]格式:kill [-s signal|-p] [-q sigval] [-a] [–] pid…
    编号 PID:指定信号模式编号管理进程;推荐用此模式操作
    -signal PID:指定信号模式管理进程;[/v_act]

[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4280 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       1876  0.0  0.0 112704   960 pts/0    S+   01:29   0:00  |       \_ grep --color=auto sshd
root       1851  0.0  0.0 157208  5816 ?        Ss   01:29   0:00  \_ sshd: yvan [priv]
yvan       1853  0.0  0.0 157208  2300 ?        S    01:29   0:00      \_ sshd: yvan@pts/1
[root@localhost ~]# kill 1851
[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4280 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       1882  0.0  0.0 112704   960 pts/0    S+   01:30   0:00          \_ grep --color=auto sshd
[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4320 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       1909  0.0  0.0 112704   964 pts/0    S+   01:31   0:00  |       \_ grep --color=auto sshd
root       1884  0.1  0.0 157208  5816 ?        Ss   01:31   0:00  \_ sshd: yvan [priv]
yvan       1886  0.0  0.0 157208  2300 ?        S    01:31   0:00      \_ sshd: yvan@pts/1
[root@localhost ~]# kill 2 1884
[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4320 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       1913  0.0  0.0 112704   960 pts/0    S+   01:32   0:00          \_ grep --color=auto sshd
[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4320 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       2156  0.0  0.0 112704   960 pts/0    S+   01:47   0:00  |       \_ grep --color=auto sshd
root       2131  0.2  0.0 157208  5816 ?        Ss   01:46   0:00  \_ sshd: yvan [priv]
yvan       2133  0.0  0.0 157208  2304 ?        S    01:46   0:00      \_ sshd: yvan@pts/1
[root@localhost ~]# kill -sigkill 2133
[root@localhost ~]# ps auxf |grep sshd
root       1698  0.0  0.0 112812  4320 ?        Ss   00:58   0:00 /usr/sbin/sshd -D
root       1699  0.0  0.0 157208  5884 ?        Ss   00:58   0:00  \_ sshd: root@pts/0
root       2160  0.0  0.0 112704   964 pts/0    S+   01:47   0:00          \_ grep --color=auto sshd

正文完
 0
Yvan
版权声明:本站原创文章,由 Yvan 于2017-04-25发表,共计2782字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)