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

OPERANDS

127       pattern
128              Specifies an Extended Regular Expression  for  matching  against
129              the process names or command lines.
130

EXAMPLES

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

EXIT STATUS

149       0      One or more processes matched the criteria.
150       1      No processes matched.
151       2      Syntax error in the command line.
152       3      Fatal error: out of memory etc.
153

NOTES

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

BUGS

162       The  options  -n and -o and -v can not be combined.  Let me know if you
163       need to do this.
164
165       Defunct processes are reported.
166
167

SEE ALSO

169       ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)
170

STANDARDS

172       pkill and pgrep were introduced in Sun's Solaris 7.   This  implementa‐
173       tion is fully compatible.
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                        October 2012                         PGREP(1)
Impressum