Linux进程管理命令-kill | IT运维网
  • 本站启用了账户登录密码错误就锁定模式,如有人误操作被锁请邮件(yvan.lu@ityww.cn)告知我账户名。
  • 本站为个人技术性站点,上面会更新一些系统、网络、虚拟化及云计算等相关的文章,与大家一起参考、学习和交流。
  • 欢迎访问本网站;本站QQ交流群:654792529;如果您觉得本站非常有看点,那么赶紧使用Ctrl+D收藏吧!

Linux进程管理命令-kill

Linux 基础 yvan 7年前 (2017-04-24) 2843次浏览 已收录 0个评论 扫描二维码
格式:kill -l [signal]
    -l:显示当前系统可用信号
[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

格式:kill [-s signal|-p] [-q sigval] [-a] [–] pid…
    编号 PID:指定信号模式编号管理进程;推荐用此模式操作
    -signal PID:指定信号模式管理进程;

[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

IT运维网 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Linux进程管理命令-kill
喜欢 (3)
yvan
关于作者:
聪明来自勤奋、知识在于积累、好记性不如烂键盘!

您必须 登录 才能发表评论!