killall 功能说明:直接使用 killall 进程名 来终止进程。 参数选项: -u 终止指定用户的进程。 -v 报告信号是否发送成功。 -e 对于很长的名字,要求能够准确匹配。默认情况下,如果一个进程名的长度超过了15个字符,则无法使用整个名字(溢出了)。 在这种情况下,killall会会终止所有匹配名字前15个字符的所有进程。而此参数的作用是忽略模糊匹配项目。 如果同时指定了-v参数,则killall会针对每个忽略的记录打印一条消息。 -I 不区分大小写匹配。 -g 终止属于该进程组的进程。 -i 在终止前询问是否确认。 -l 列出所有已知的信号名。 -q 如果没有进程终止则不提示。 -r 使用正则表达式匹配要终止的进程名称。 -s 用指定的信号代替默认信号。 -w 等待所有被终止的进程死去。killall每秒都会检查一次被终止的进程是否仍然存在,其仅在都死光后才返回。 注意:如果信号被忽略,或者没有起作用,或者进程停留在僵尸状态,那么killall可能会被永久等待。 [root@testdb62 ~]# ps -ef|grep crond root 1004 1 0 Oct13 ? 00:01:09 /usr/sbin/crond -n root 3170 28772 0 11:44 pts/0 00:00:00 grep --color=auto crond [root@testdb62 ~]# killall crond [root@testdb62 ~]# ps -ef|grep crond root 3192 28772 0 11:44 pts/0 00:00:00 grep --color=auto crond [root@testdb62 ~]# killall crond crond: no process found [root@testdb62 ~]# systemctl start crond [root@testdb62 ~]# ps -ef|grep crond root 3259 1 0 11:45 ? 00:00:00 /usr/sbin/crond -n root 3275 28772 0 11:45 pts/0 00:00:00 grep --color=auto crond [root@testdb62 ~]# killall -w crond [root@testdb62 ~]# killall -u mysql [root@testdb62 ~]# ps -ef|grep mysql root 8549 28772 0 13:34 pts/0 00:00:00 grep --color=auto mysql
原文:https://www.cnblogs.com/l10n/p/14172483.html