PIDs from file. This option is more useful for pkill or
pidwait than pgrep.
-L, --logpidfile
Fail if pidfile (see -F) not locked.
-r, --runstates D,R,S,Z,...
Match only processes which match the process state.
-A, --ignore‐ancestors
Ignore all ancestors of pgrep, pkill, or pidwait. For example,
this can be useful when elevating with sudo or similar tools.
-H, --require-handler
Only match processes with a userspace signal handler present for
the signal to be sent.
--cgroup name,...
Match on provided control group (cgroup) v2 name. See cgroups(8)
--ns pid
Match processes that belong to the same namespaces. Required to
run as root to match processes from other users. See --nslist for
how to limit which namespaces to match.
--nslist name,...
Match only the provided namespaces. Available namespaces: ipc,
mnt, net, pid, user, uts.
-q, --queue value
Use sigqueue(3) rather than kill(2) and the value argument is
used to specify an integer to be sent with the signal. If the re‐
ceiving process has installed a handler for this signal using the
SA_SIGINFO flag to sigaction(2), then it can obtain this data via
the si_value field of the siginfo_t structure.
-V, --version
Display version information and exit.
-h, --help
Display help and exit.
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:
$ pgrep -u root named
Example 2: Make syslog reread its configuration file:
$ pkill -HUP syslogd
Example 3: Give detailed information on all xterm processes:
$ ps -fp $(pgrep -d, -x xterm)
Example 4: Make all chrome processes run nicer:
$ renice +4 $(pgrep chrome)
EXIT STATUS
0 One or more processes matched the criteria. For pkill and pid‐
wait, one or more processes must also have been successfully sig‐
nalled or waited for.
1 No processes matched or none of them could be signalled.
2 Syntax error in the command line.
3 Fatal error: out of memory etc.
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. Threads may not
have the same process name as the parent process but will have the same
command line.
The running pgrep, pkill, or pidwait process will never report itself as
a match.
The -O --older option will silently fail if /proc is mounted with the
subset=pid option.
BUGS
The options -n and -o and -v can not be combined. Let me know if you
need to do this.
Defunct processes are reported.
pidwait requires the pidfd_open(2) system call which first appeared in
Linux 5.3.
SEE ALSO
ps(1), regex(7), signal(7), sigqueue(3), killall(1), skill(1), kill(1),
kill(2), cgroups(8).
AUTHOR
Kjetil Torgrim Homme
REPORTING BUGS
Please send bug reports to procps@freelists.org
procps‐ng 2023‐01‐16 PGREP(1)