2 .\" Copyright 2000 Kjetil Torgrim Homme
3 .\" 2017-2020 Craig Small
5 .\" This program is free software; you can redistribute it and/or modify
6 .\" it under the terms of the GNU General Public License as published by
7 .\" the Free Software Foundation; either version 2 of the License, or
8 .\" (at your option) any later version.
10 .TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
12 pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and other attributes
24 looks through the currently running processes and lists the process IDs which
25 match the selection criteria to stdout. All the criteria have to match.
30 will only list the processes called
36 $ pgrep \-u root,daemon
38 will list the processes owned by
44 will send the specified signal (by default
46 to each process instead of listing them on stdout.
49 will wait for each process instead of listing them on stdout.
54 \fB\-\-signal\fR \fIsignal\fR
55 Defines the signal to send to each matched process. Either the numeric or
56 the symbolic signal name can be used.
60 \fB\-c\fR, \fB\-\-count\fR
61 Suppress normal output; instead print a count of matching processes. When
62 count does not match anything, e.g. returns zero, the command will return
63 non-zero value. Note that for pkill and pwait, the count is the number of
64 matching processes, not the processes that were successfully signaled or waited
67 \fB\-d\fR, \fB\-\-delimiter\fR \fIdelimiter\fP
68 Sets the string used to delimit each process ID in the output (by default a
73 \fB\-e\fR, \fB\-\-echo\fR
74 Display name and PID of the process being killed.
78 \fB\-f\fR, \fB\-\-full\fR
81 is normally only matched against the process name. When
83 is set, the full command line is used.
85 \fB\-g\fR, \fB\-\-pgroup\fR \fIpgrp\fP,...
86 Only match processes in the process group IDs listed. Process group 0 is
94 \fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
95 Only match processes whose real group ID is listed. Either the numerical or
96 symbolical value may be used.
98 \fB\-i\fR, \fB\-\-ignore\-case\fR
99 Match processes case-insensitively.
101 \fB\-l\fR, \fB\-\-list\-name\fR
102 List the process name as well as the process ID.
106 \fB\-a\fR, \fB\-\-list\-full\fR
107 List the full command line as well as the process ID.
111 \fB\-n\fR, \fB\-\-newest\fR
112 Select only the newest (most recently started) of the matching processes.
114 \fB\-o\fR, \fB\-\-oldest\fR
115 Select only the oldest (least recently started) of the matching processes.
117 \fB\-O\fR, \fB\-\-older\fR \fIsecs\fP
118 Select processes older than secs.
120 \fB\-P\fR, \fB\-\-parent\fR \fIppid\fP,...
121 Only match processes whose parent process ID is listed.
123 \fB\-s\fR, \fB\-\-session\fR \fIsid\fP,...
124 Only match processes whose process session ID is listed. Session ID 0
132 \fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
133 Only match processes whose controlling terminal is listed. The terminal name
134 should be specified without the "/dev/" prefix.
136 \fB\-u\fR, \fB\-\-euid\fR \fIeuid\fP,...
137 Only match processes whose effective user ID is listed. Either the numerical
138 or symbolical value may be used.
140 \fB\-U\fR, \fB\-\-uid\fR \fIuid\fP,...
141 Only match processes whose real user ID is listed. Either the numerical or
142 symbolical value may be used.
144 \fB\-v\fR, \fB\-\-inverse\fR\fR
145 Negates the matching. This option is usually used in
151 context the short option is disabled to avoid accidental usage of the option.
153 \fB\-w\fR, \fB\-\-lightweight\fR\fR
154 Shows all thread ids instead of pids in
160 context this option is disabled.
162 \fB\-x\fR, \fB\-\-exact\fR\fR
163 Only match processes whose names (or command lines if \fB\-f\fR is specified)
168 \fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
169 Read \fIPID\fRs from \fIfile\fR. This option is more useful for
174 \fB\-L\fR, \fB\-\-logpidfile\fR
175 Fail if pidfile (see \fB\-F\fR) not locked.
177 \fB\-r\fR, \fB\-\-runstates\fR \fID,R,S,Z,\fP...
178 Match only processes which match the process state.
181 Match processes that belong to the same namespaces. Required to run as
182 root to match processes from other users. See \fB\-\-nslist\fR for how to
183 limit which namespaces to match.
185 \fB\-\-nslist \fIname\fP,...
186 Match only the provided namespaces. Available namespaces:
187 ipc, mnt, net, pid, user,uts.
189 \fB\-q\fR, \fB\-\-queue \fIvalue\fP
194 and the value argument is used to specify
195 an integer to be sent with the signal. If the receiving process has
196 installed a handler for this signal using the SA_SIGINFO flag to
198 , then it can obtain this data via the si_value field of the
201 \fB\-V\fR, \fB\-\-version\fR
202 Display version information and exit.
204 \fB\-h\fR, \fB\-\-help\fR
205 Display help and exit.
210 Specifies an Extended Regular Expression for matching against the process
211 names or command lines.
213 Example 1: Find the process ID of the
217 $ pgrep \-u root named
221 reread its configuration file:
223 $ pkill \-HUP syslogd
225 Example 3: Give detailed information on all
229 $ ps \-fp $(pgrep \-d, \-x xterm)
235 $ renice +4 $(pgrep chrome)
240 One or more processes matched the criteria. For pkill and pwait, one or more
241 processes must also have been successfully signalled or waited for.
244 No processes matched or none of them could be signalled.
247 Syntax error in the command line.
250 Fatal error: out of memory etc.
253 The process name used for matching is limited to the 15 characters present in
254 the output of /proc/\fIpid\fP/stat. Use the \fB\-f\fR option to match against the
255 complete command line, /proc/\fIpid\fP/cmdline.
262 process will never report itself as a
271 can not be combined. Let
272 me know if you need to do this.
274 Defunct processes are reported.
286 .UR kjetilho@ifi.uio.no
290 Please send bug reports to
291 .UR procps@freelists.org