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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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

OPERANDS

136       pattern
137              Specifies an Extended Regular Expression  for  matching  against
138              the process names or command lines.
139

EXAMPLES

141       Example 1: Find the process ID of the named daemon:
142
143              $ pgrep -u root named
144
145       Example 2: Make syslog reread its configuration file:
146
147              $ pkill -HUP syslogd
148
149       Example 3: Give detailed information on all xterm processes:
150
151              $ ps -fp $(pgrep -d, -x xterm)
152
153       Example 4: Make all chrome processes run nicer:
154
155              $ renice +4 $(pgrep chrome)
156

EXIT STATUS

158       0      One  or  more  processes  matched  the  criteria.  For pkill the
159              process must also have been successfully signalled.
160       1      No processes matched or none of them could be signalled.
161       2      Syntax error in the command line.
162       3      Fatal error: out of memory etc.
163

NOTES

165       The process name used for matching is  limited  to  the  15  characters
166       present  in  the  output of /proc/pid/stat.  Use the -f option to match
167       against the complete command line, /proc/pid/cmdline.
168
169       The running pgrep or pkill process will never report itself as a match.
170

BUGS

172       The options -n and -o and -v can not be combined.  Let me know  if  you
173       need to do this.
174
175       Defunct processes are reported.
176
177

SEE ALSO

179       ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)
180

AUTHOR

182       Kjetil Torgrim Homme ⟨kjetilho@ifi.uio.no⟩
183

REPORTING BUGS

185       Please send bug reports to ⟨procps@freelists.org⟩
186
187
188
189procps-ng                         2019-03-05                          PGREP(1)
Impressum