用法示例
# 根据名称过滤
dewan Work ~/code/shell% pgrep qemu
3570191
dewan Work ~/code/shell% pgrep qemu -l
3570191 qemu-system-x86
dewan Work ~/code/shell% pgrep qemu -a
3570191 /usr/bin/qemu-system-x86_64 -name guest=centos7,debug-threads=on ...
# 根据运行状态过滤
dewan Work ~/code/shell% pgrep -ar R  # R,running 就绪状态
2261 /usr/bin/gnome-shell
3804 /usr/libexec/gnome-terminal-server
命令帮助
dewan Work ~/code/shell% pgrep -h
用法:
 pgrep [options] <pattern>
选项:
 -d, --delimiter <string>  specify output delimiter
 -l, --list-name           list PID and process name
 -a, --list-full           list PID and full command line
 -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 <PGID,...>   match listed process group IDs
 -G, --group <GID,...>     match real group IDs
 -i, --ignore-case         match case insensitively
 -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
 -r, --runstates <state>   match runstates [D,S,Z,...]
 --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     显示此帮助然后离开
 -V, --version  显示程序版本然后离开
欲了解更多详细信息,请参见 pgrep(1)。