1PGREP(1)                         User Commands                        PGREP(1)
2
3
4

NAME

6       pgrep, pkill, pidwait - look up, signal, or wait for processes based on
7       name and other attributes
8

SYNOPSIS

10       pgrep [options] pattern
11       pkill [options] pattern
12       pidwait [options] pattern
13

DESCRIPTION

15       pgrep looks through the  currently  running  processes  and  lists  the
16       process IDs which match the selection criteria to stdout.  All the cri‐
17       teria have to match.  For example,
18
19              $ pgrep -u root sshd
20
21       will only list the processes called sshd AND owned  by  root.   On  the
22       other hand,
23
24              $ pgrep -u root,daemon
25
26       will list the processes owned by root OR daemon.
27
28       pkill  will  send  the  specified  signal  (by default SIGTERM) to each
29       process instead of listing them on stdout.
30
31       pidwait will wait for each process instead of listing them on stdout.
32

OPTIONS

34       -signal
35       --signal signal
36              Defines the signal to send to each matched process.  Either  the
37              numeric or the symbolic signal name can be used.  (pkill only.)
38
39       -c, --count
40              Suppress  normal  output; instead print a count of matching pro‐
41              cesses.  When count does not match anything, e.g. returns  zero,
42              the  command will return non-zero value. Note that for pkill and
43              pidwait, the count is the number of matching processes, not  the
44              processes that were successfully signaled or waited for.
45
46       -d, --delimiter delimiter
47              Sets  the  string  used to delimit each process ID in the output
48              (by default a newline).  (pgrep only.)
49
50       -e, --echo
51              Display name and PID of the process being killed.  (pkill only.)
52
53       -f, --full
54              The pattern is normally only matched against the  process  name.
55              When -f is set, the full command line is used.
56
57       -g, --pgroup pgrp,...
58              Only  match  processes in the process group IDs listed.  Process
59              group 0 is translated into pgrep's, pkill's,  or  pidwait's  own
60              process group.
61
62       -G, --group gid,...
63              Only  match processes whose real group ID is listed.  Either the
64              numerical or symbolical value may be used.
65
66       -i, --ignore-case
67              Match processes case-insensitively.
68
69       -l, --list-name
70              List the process name as well as the process ID.  (pgrep only.)
71
72       -a, --list-full
73              List the full command line as well as the  process  ID.   (pgrep
74              only.)
75
76       -n, --newest
77              Select  only  the newest (most recently started) of the matching
78              processes.
79
80       -o, --oldest
81              Select only the oldest (least recently started) of the  matching
82              processes.
83
84       -O, --older secs
85              Select processes older than secs.
86
87       -P, --parent ppid,...
88              Only match processes whose parent process ID is listed.
89
90       -s, --session sid,...
91              Only  match  processes whose process session ID is listed.  Ses‐
92              sion ID 0 is translated into pgrep's, pkill's, or pidwait's  own
93              session ID.
94
95       -t, --terminal term,...
96              Only  match processes whose controlling terminal is listed.  The
97              terminal name should be specified without the "/dev/" prefix.
98
99       -u, --euid euid,...
100              Only match processes whose effective user ID is listed.   Either
101              the numerical or symbolical value may be used.
102
103       -U, --uid uid,...
104              Only  match  processes whose real user ID is listed.  Either the
105              numerical or symbolical value may be used.
106
107       -v, --inverse
108              Negates the matching.  This option is usually used in pgrep's or
109              pidwait's  context.  In pkill's context the short option is dis‐
110              abled to avoid accidental usage of the option.
111
112       -w, --lightweight
113              Shows all thread ids instead of pids  in  pgrep's  or  pidwait's
114              context.  In pkill's context this option is disabled.
115
116       -x, --exact
117              Only  match  processes  whose  names  (or command lines if -f is
118              specified) exactly match the pattern.
119
120       -F, --pidfile file
121              Read PIDs from file.  This option is more useful for pkillorpid‐
122              wait than pgrep.
123
124       -L, --logpidfile
125              Fail if pidfile (see -F) not locked.
126
127       -r, --runstates D,R,S,Z,...
128              Match only processes which match the process state.
129
130       --ns pid
131              Match  processes that belong to the same namespaces. Required to
132              run as root to match processes from other  users.  See  --nslist
133              for how to limit which namespaces to match.
134
135       --nslist name,...
136              Match  only  the provided namespaces. Available namespaces: ipc,
137              mnt, net, pid, user,uts.
138
139       -q, --queue value
140              Use sigqueue(3) rather than kill(2) and the  value  argument  is
141              used  to  specify  an integer to be sent with the signal. If the
142              receiving process has installed a handler for this signal  using
143              the  SA_SIGINFO  flag  to sigaction(2) , then it can obtain this
144              data via the si_value field of the siginfo_t structure.
145
146       -V, --version
147              Display version information and exit.
148
149       -h, --help
150              Display help and exit.
151

OPERANDS

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

EXAMPLES

158       Example 1: Find the process ID of the named daemon:
159
160              $ pgrep -u root named
161
162       Example 2: Make syslog reread its configuration file:
163
164              $ pkill -HUP syslogd
165
166       Example 3: Give detailed information on all xterm processes:
167
168              $ ps -fp $(pgrep -d, -x xterm)
169
170       Example 4: Make all chrome processes run nicer:
171
172              $ renice +4 $(pgrep chrome)
173

EXIT STATUS

175       0      One  or  more processes matched the criteria. For pkill and pid‐
176              wait, one or more processes must  also  have  been  successfully
177              signalled or waited for.
178       1      No processes matched or none of them could be signalled.
179       2      Syntax error in the command line.
180       3      Fatal error: out of memory etc.
181

NOTES

183       The  process  name  used  for  matching is limited to the 15 characters
184       present in the output of /proc/pid/stat.  Use the -f  option  to  match
185       against the complete command line, /proc/pid/cmdline.
186
187       The  running  pgrep, pkill, or pidwait process will never report itself
188       as a match.
189

BUGS

191       The options -n and -o and -v can not be combined.  Let me know  if  you
192       need to do this.
193
194       Defunct processes are reported.
195
196

SEE ALSO

198       ps(1), regex(7), signal(7), sigqueue(3), killall(1), skill(1), kill(1),
199       kill(2)
200

AUTHOR

202       Kjetil Torgrim Homme ⟨kjetilho@ifi.uio.no⟩
203

REPORTING BUGS

205       Please send bug reports to ⟨procps@freelists.org⟩
206
207
208
209procps-ng                         2020-06-04                          PGREP(1)
Impressum