killall (强制终止指定名字的进程)

喵喵 发表于 2020-07-11 03:54
浏览次数:
在手机上阅读

在类似Unix的操作系统上,KILLALL命令强制终止指定名字的进程.

本文档描述了KILLALL的GNU/Linux版本。

This document describes the GNU/Linux version of killall.

查看英文版

目录

1 killall 运行系统环境

2 killall 描述

3 killall 语法

4 killall 建议

5 killall 已知错误

6 killall 示例

killall 运行系统环境

Linux

killall 描述

KILLALL向运行任何指定命令的所有进程发送信号。如果没有指定信号名,则发送SIGTERM。 信号可以通过名称(例如-HUP或-SIGHUP)或数字(例如-1)或选项-s来指定。 如果命令名不是正则表达式(Option-r),并且包含斜杠(/),则将选择执行该特定文件的进程,与其名称无关。 如果每个列出的命令至少有一个进程被终止,或者没有列出命令,并且至少有一个进程符合-u和-Z搜索条件,则KILLALL返回一个零返回代码。否则KILLALL返回非零。 KILLALL进程永远不会终止自己(但可能会终止其他KILLALL进程)。
killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.
Signals can be specified either by name (e.g., -HUP or -SIGHUP) or by number (e.g., -1) or by option -s.
If the command name is not a regular expression (option -r) and contains a slash (/), processes executing that particular file will be selected for killing, independent of their name.
killall returns a zero return code if at least one process has been killed for each listed command, or no commands were listed and at least one process matched the -u and -Z search criteria. killall returns non-zero otherwise.
A killall process never kills itself (but may kill other killall processes).

查看英文版

查看中文版

killall 语法

killall [-Z, --context pattern] [-e, --exact] [-g, --process-group]
        [-i, --interactive] [-o, --older-than TIME] [-q, --quiet]
        [-r, --regexp] [-s, --signal signal] [-u, --user user]
        [-v, --verbose] [-w, --wait] [-y, --younger-than TIME]
        [-I, --ignore-case] [-V, --version] [--] name ...
killall -l
killall -V, --version
killall [-Z, --context pattern] [-e, --exact] [-g, --process-group]
        [-i, --interactive] [-o, --older-than TIME] [-q, --quiet]
        [-r, --regexp] [-s, --signal signal] [-u, --user user]
        [-v, --verbose] [-w, --wait] [-y, --younger-than TIME]
        [-I, --ignore-case] [-V, --version] [--] name ...
killall -l
killall -V, --version

查看英文版

查看中文版

killall 建议

-e--exact 很长的名字需要完全匹配。如果命令名超过15个字符,则全名可能不可用(即它被替换掉)。在这种情况下,KILLALL将终止前15个字符中匹配的所有内容。使用-e时,这样的条目将被跳过。KILLALL为除-e之外指定的每个跳过的条目(if-v)打印一条消息。
-I--ignore-case 执行不区分大小写的进程名匹配。
-g--process-group 终止进程所属的进程组。即使找到属于同一进程组的多个进程,每个组只发送一次终止信号。
-i--interactive 在终止前互相询问确认。
-l--list 列出所有已知的信号名。
-o--older-than 只匹配较早(在指定时间之前开始)的进程。时间被指定为浮动,然后是一个单元。单位分别为s、m、h、d、w、m、y,分别为秒、分钟、小时、日、周、月和年。
-q--quiet 如果没有进程被终止,不要抱怨。
-r--regexp 将进程名模式解释为扩展的正则表达式。
-s--signal 发送这个信号而不是SIGTERM。
-u--user 只终止指定用户拥有的进程。命令名是可选的。
-v--verbose 如果信号发送成功,请报告。
-V--version 显示版本信息。
-w--wait 等待所有被终止的进程终止。KILLALL每秒钟检查一次是否仍然存在任何已终止的进程,只有在没有剩余的情况下才返回。注意,如果信号被忽略,没有效果,或者进程处于僵尸状态,KILLALL可能会永远等待。
-y--younger-than 只匹配较年轻的进程(在指定的时间之后启动)。时间被指定为浮动,然后是一个单元。单位分别为s、m、h、d、w、m、y,分别为秒、分钟、小时、日、周、月和年。
-Z--context (仅SELinux)指定安全上下文:只终止具有与给定的扩展正则表达式模式匹配的安全上下文的进程。必须在命令行的其他参数之前。命令名是可选的。
-e--exact Require an exact match for very long names. If a command name is longer than 15 characters, the full name may be unavailable (i.e. it is swapped out). In this case, killall will kill everything that matches within the first 15 characters. With -e, such entries are skipped. killallprints a message for each skipped entry if -v is specified in addition to -e.
-I--ignore-case Do case insensitive process name match.
-g--process-group Kill the process group to which the process belongs. The kill signal is only sent once per group, even if multiple processes belonging to the same process group were found.
-i--interactive Interactively ask for confirmation before killing.
-l--list List all known signal names.
-o--older-than Match only processes that are older (started before) the time specified. The time is specified as a float then a unit. The units are s,m,h,d,w,M,yfor seconds, minutes, hours, days, weeks, Months, and years respectively.
-q--quiet Do not complain if no processes were killed.
-r--regexp Interpret process name pattern as an extended regular expression.
-s--signal Send this signal instead of SIGTERM.
-u--user Kill only processes the specified user owns. Command names are optional.
-v--verbose Report if the signal was successfully sent.
-V--version Display version information.
-w--wait Wait for all killed processes to die. killall checks once per second if any of the killed processes still exist and only returns if none are left. Note that killall may wait forever if the signal was ignored, had no effect, or if the process stays in zombie state.
-y--younger-than Match only processes that are younger (started after) the time specified. The time is specified as a float then a unit. The units are s,m,h,d,w,M,yfor seconds, minutes, hours, days, weeks, Months, and years respectively.
-Z--context (SELinux Only) Specify security context: kill only processes having security context that match with given expended regular expression pattern. Must precede other arguments on the command line. Command names are optional.

查看英文版

查看中文版

killall 已知错误

文件终止只适用于在执行过程中保持打开状态的可执行文件,即无法以这种方式终止不纯的可执行文件。
请注意,键入KILLALL名称可能不会在非Linux系统上产生预期的效果,特别是在特权用户执行时。
KILLALL-w不检测进程是否消失,并由扫描之间具有相同PID的新进程替换。
如果进程更改其名称,则KILLALL可能无法正确匹配它们。
KILLALL有一个可以在命令行上指定的名称的限制。这个数字是无符号长乘以8的大小。对于大多数32位系统,极限是32,对于64位系统,限制通常是64。
Killing by file only works for executables that are kept open during execution, i.e. impure executables can't be killed this way.
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
killall -w doesn't detect if a process disappears and is replaced by a new process with the same PID between scans.
If processes change their name, killall may not be able to match them correctly.
killall has a limit of names that can be specified on the command line. This figure is the size of an unsigned long multiplied by 8. For most 32 bit systems the limit is 32 and similarly for a 64 bit system the limit is usually 64.

查看英文版

查看中文版

killall 示例

killall UnResponsiveProg
终止名为“unResponsiveProg”的进程。
killall -I unresponsiveprog
终止任何与字符串“unresponsiveprog”匹配的进程,忽略大小写字母之间的差异。
killall UnResponsiveProg
Terminate the process named "UnResponsiveProg".
killall -I unresponsiveprog
Terminate any process matching the string "unresponsiveprog", ignoring the difference between upper- and lowercase letters.

查看英文版

查看中文版

其他命令行

keylogin | kill |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条