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       -f, --full
46              The pattern is normally only matched against the  process  name.
47              When -f is set, the full command line is used.
48
49       -g, --pgroup pgrp,...
50              Only  match  processes in the process group IDs listed.  Process
51              group 0 is translated into pgrep's or pkill's own process group.
52
53       -G, --group gid,...
54              Only match processes whose real group ID is listed.  Either  the
55              numerical or symbolical value may be used.
56
57       -i, --ignore-case
58              Match processes case-insensitively.
59
60       -l, --list-name
61              List the process name as well as the process ID.  (pgrep only.)
62
63       -a, --list-full
64              List  the  full  command line as well as the process ID.  (pgrep
65              only.)
66
67       -n, --newest
68              Select only the newest (most recently started) of  the  matching
69              processes.
70
71       -o, --oldest
72              Select  only the oldest (least recently started) of the matching
73              processes.
74
75       -P, --parent ppid,...
76              Only match processes whose parent process ID is listed.
77
78       -s, --session sid,...
79              Only match processes whose process session ID is  listed.   Ses‐
80              sion ID 0 is translated into pgrep's or pkill's own session ID.
81
82       -t, --terminal term,...
83              Only  match processes whose controlling terminal is listed.  The
84              terminal name should be specified without the "/dev/" prefix.
85
86       -u, --euid euid,...
87              Only match processes whose effective user ID is listed.   Either
88              the numerical or symbolical value may be used.
89
90       -U, --uid uid,...
91              Only  match  processes whose real user ID is listed.  Either the
92              numerical or symbolical value may be used.
93
94       -v, --inverse
95              Negates the matching.  This option is usually  used  in  pgrep's
96              context.   In  pkill's  context  the short option is disabled to
97              avoid accidental usage of the option.
98
99       -w, --lightweight
100              Shows all thread ids instead of pids  in  pgrep's  context.   In
101              pkill's context this option is disabled.
102
103       -x, --exact
104              Only match processes whose names (or command line if -f is spec‐
105              ified) exactly match the pattern.
106
107       -F, --pidfile file
108              Read PID's from file.  This option is perhaps  more  useful  for
109              pkill than pgrep.
110
111       -L, --logpidfile
112              Fail if pidfile (see -F) not locked.
113
114       --ns pid
115              Match  processes that belong to the same namespaces. Required to
116              run as root to match processes from other  users.  See  --nslist
117              for how to limit which namespaces to match.
118
119       --nslist name,...
120              Match  only  the provided namespaces. Available namespaces: ipc,
121              mnt, net, pid, user,uts.
122
123       -V, --version
124              Display version information and exit.
125
126       -h, --help
127              Display help and exit.
128

OPERANDS

130       pattern
131              Specifies an Extended Regular Expression  for  matching  against
132              the process names or command lines.
133

EXAMPLES

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

EXIT STATUS

152       0      One  or  more  processes  matched  the  criteria.  For pkill the
153              process must also have been successfully signalled.
154       1      No processes matched or none of them could be signalled.
155       2      Syntax error in the command line.
156       3      Fatal error: out of memory etc.
157

NOTES

159       The process name used for matching is  limited  to  the  15  characters
160       present  in  the  output of /proc/pid/stat.  Use the -f option to match
161       against the complete command line, /proc/pid/cmdline.
162
163       The running pgrep or pkill process will never report itself as a match.
164

BUGS

166       The options -n and -o and -v can not be combined.  Let me know  if  you
167       need to do this.
168
169       Defunct processes are reported.
170
171

SEE ALSO

173       ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)
174

AUTHOR

176       Kjetil Torgrim Homme ⟨kjetilho@ifi.uio.no⟩
177

REPORTING BUGS

179       Please send bug reports to ⟨procps@freelists.org⟩
180
181
182
183procps-ng                         2017-12-22                          PGREP(1)
Impressum