pkill 命令_pkill和pgrep:流程管理命令

pkill 命令

This is a introduction to *nix’s process management tools: pkill and pgrep. As this site’s domain name was pkill.info, a introduction to pkill should exist here.

这是* nix的流程管理工具的简介:pkill和pgrep。 由于该站点的域名是pkill.info,因此此处应该存在pkill的简介。

名称 (NAME)

pgrep, pkill – look up or signal processes based on name and other attributes

pgrep,pkill –根据名称和其他属性查找或通知进程

概要 (SYNOPSIS)

pgrep [-flvx] [-d delimiter] [-n|-o] [-P ppid,...] [-g pgrp,...]
[-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]
[-t term,...] [pattern]

pkill [-signal] [-fvx] [-n|-o] [-P ppid,...] [-g pgrp,...]
[-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]
[-t term,...] [pattern]

描述 (DESCRIPTION)

pgrep  looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.  All the criteria have to match.  For example,

pgrep查看当前正在运行的进程,并列出与选择标准匹配到stdout的进程ID。 所有条件都必须匹配。 例如,

pgrep -u root sshd

will only list the processes called sshd AND owned by root.  On the other hand,

只会列出root拥有的名为sshd AND的进程。 另一方面,

pgrep -u root,daemon

will list the processes owned by root OR daemon.

将列出root OR守护程序拥有的进程。

pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

pkill将向每个进程发送指定的信号(默认为SIGTERM),而不是在stdout上列出它们。

选件 (OPTIONS)

-d delimiter
Sets the string used to delimit each process ID in the output (by default a newline).  (pgrep only.)

-d分隔符
设置用于分隔输出中每个进程ID的字符串(默认情况下为换行符)。 (仅限pgrep。)

-f The pattern is normally only matched against the process name.  When -f is set, the full command  line  is used.

-f该模式通常仅与进程名称匹配。 设置-f时,将使用完整的命令行。

-g pgrp,…
Only  match  processes  in  the  process  group IDs listed.  Process group 0 is translated into pgrep’s or pkill’s own process group.

-g pgrp,…
仅匹配列出的进程组ID中的进程。 进程组0转换为pgrep或pkill自己的进程组。

-G gid,…
Only match processes whose real group ID is listed.  Either the numerical or symbolical value may be used.

-G gid,…
仅匹配列出了真实组ID的进程。 可以使用数值或符号值。

-l List the process name as well as the process ID. (pgrep only.)

-l列出进程名称以及进程ID。 (仅限pgrep。)

-n Select only the newest (most recently started) of the matching processes.

-n仅选择最新的(最近启动的)匹配过程。

-o Select only the oldest (least recently started) of the matching processes.

-o仅选择最旧的(最近启动的)匹配过程。

-P ppid,…
Only match processes whose parent process ID is listed.

-P ppid,…
仅匹配列出其父进程ID的进程。

-s sid,…
Only  match  processes  whose  process  session  ID is listed.  Session ID 0 is translated into pgrep’s or pkill’s own session ID.

-s sid,…
仅匹配列出了进程会话ID的进程。 会话ID 0转换为pgrep或pkill自己的会话ID。

-t term,…
Only match processes whose controlling terminal is listed.  The terminal name should be specified  without the “/dev/” prefix.

-t学期,…
仅匹配列出其控制终端的进程。 终端名称应不带“ / dev /”前缀。

-u euid,…
Only  match  processes whose effective user ID is listed.  Either the numerical or symbolical value may be used.

-u euid,…
仅匹配列出了有效用户ID的进程。 可以使用数值或符号值。

-U uid,…
Only match processes whose real user ID is listed.  Either the numerical or symbolical value may be  used.

-U uid,...
仅匹配列出了真实用户ID的进程。 可以使用数值或符号值。

-v Negates the matching.

-v取消匹配。

-x Only match processes whose name (or command line if -f is specified) exactly match the pattern.

-x仅匹配名称(或命令行,如果指定-f)与模式完全匹配的进程。

-signal
Defines the signal to send to each matched process.  Either the numeric or the symbolic signal name can be used.  (pkill only.)

-信号
定义要发送到每个匹配进程的信号。 可以使用数字或符号信号名称。 (仅限技能)。

经营者 (OPERANDS)

pattern
Specifies an Extended Regular Expression for matching against the process names or command lines.

模式
指定扩展正则表达式以与进程名称或命令行匹配。

例子 (EXAMPLES)

Example 1: Find the process ID of the named daemon:

示例1:查找命名守护程序的进程ID:

unix$ pgrep -u root named

Example 2: Make syslog reread its configuration file:

示例2:使syslog重新读取其配置文件:

unix$ pkill -HUP syslogd

Example 3: Give detailed information on all xterm processes:

示例3:提供有关所有xterm流程的详细信息:

unix$ ps -fp $(pgrep -d, -x xterm)

Example 4: Make all netscape processes run nicer:

示例4:使所有netscape进程运行得更好:

unix$ renice +4 ‘pgrep netscape‘

退出状态 (EXIT STATUS)

0      One or more processes matched the criteria.

0一个或多个过程符合条件。

1      No processes matched.

1没有匹配的进程。

2      Syntax error in the command line.

2命令行中的语法错误

3      Fatal error: out of memory etc.

3致命错误:内存不足等。

笔记 (NOTES)

The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat.   Use the -f option to match against the complete command line, /proc/pid/cmdline.

用于匹配的进程名称限制为/ proc / pid / stat输出中存在的15个字符。 使用-f选项与完整的命令行/ proc / pid / cmdline匹配。

The running pgrep or pkill process will never report itself as a match.

正在运行的pgrep或pkill进程将永远不会将自己报告为匹配项。

臭虫 (BUGS)

The options -n and -o and -v can not be combined.  Let me know if you need to do this.

选项-n和-o和-v不能组合使用。 让我知道您是否需要这样做。

Defunct processes are reported.

已报废的进程。

也可以看看 (SEE ALSO)

ps(1) regex(7) signal(7) killall(1) skill(1) kill(1) kill(2)

ps(1)regex(7)signal(7)killall(1)技能(1)kill(1)kill(2)

标准品 (STANDARDS)

pkill and pgrep were introduced in Sun’s Solaris 7.  This implementation is fully compatible.

pkill和pgrep是在Sun的Solaris 7中引入的。此实现是完全兼容的。

作者 (AUTHOR)

Kjetil Torgrim Homme <kjetilho@ifi.uio.no>

Kjetil Torgrim Homme <kjetilho@ifi.uio.no>

Albert Cahalan <albert@users.sf.net> is the current maintainer of the procps package.

Albert Cahalan <albert@users.sf.net>是procps软件包的当前维护者。

Please send bug reports to <procps-feedback@lists.sf.net>

请将错误报告发送至<procps-feedback@lists.sf.net>

From Linux User’s Manual.

摘自《 Linux用户手册》。

翻译自: https://www.systutorials.com/pkill-and-pgrep-process-management-commands/

pkill 命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值