好记性不如铅笔头

linux, 操作系统

linux过滤进程命令pgrep简单笔记

CONTENTS

简单使用:

cstriker1407@cstriker1407-x64:~$ pgrep watchdog -l  #过滤watchdog进程的ID号和名称(启动命令)
22 watchdog/0
23 watchdog/1
28 watchdog/2
33 watchdog/3
cstriker1407@cstriker1407-x64:~$ pgrep watchdog -c #记下数目
4
cstriker1407@cstriker1407-x64:~$ pgrep watchdog #过滤watchdog进程的ID号
22
23
28
33
cstriker1407@cstriker1407-x64:~$ pgrep watchdog -u root  #过滤watchdog进程的ID号,这里还要过滤下属于root的
22
23
28
33
cstriker1407@cstriker1407-x64:~$ pgrep watchdog -u cstriker1407  #过滤watchdog进程的ID号,这里还要过滤下属于cstriker1407的

命令帮助:

cstriker1407@cstriker1407-x64:~$ pgrep --help

Usage:
 pgrep [options] <pattern>

Options:
 -d, --delimiter <string>  specify output delimiter
 -l, --list-name           list PID and process name
 -v, --inverse             negates the matching
 -w, --lightweight         list all TID
 -c, --count               count of matching processes
 -f, --full                use full process name to match
 -g, --pgroup <id,...>     match listed process group IDs
 -G, --group <gid,...>     match real group IDs
 -n, --newest              select most recently started
 -o, --oldest              select least recently started
 -P, --parent <ppid,...>   match only child processes of the given parent
 -s, --session <sid,...>   match session IDs
 -t, --terminal <tty,...>  match by controlling terminal
 -u, --euid <id,...>       match by effective IDs
 -U, --uid <id,...>        match by real IDs
 -x, --exact               match exactly with the command name
 -F, --pidfile <file>      read PIDs from file
 -L, --logpidfile          fail if PID file is not locked
 --ns <pid>                match the processes that belong to the same
                           namespace as <pid>
 --nslist <ns,...>         list which namespaces will be considered for
                           the --ns option.
                           Available namespaces: ipc, mnt, net, pid, user, uts

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see pgrep(1).

发表评论

1 × 5 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据