1PGREP(1)                      Linux User's Manual                     PGREP(1)
2
3
4

NAME

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

SYNOPSIS

11       pgrep [-flvx] [-d delimiter] [-n|-o] [-P ppid,...] [-g pgrp,...]
12            [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]
13            [-t term,...] [pattern]
14
15       pkill [-signal] [-fvx] [-n|-o] [-P ppid,...] [-g pgrp,...]
16            [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]
17            [-t term,...] [pattern]
18
19

DESCRIPTION

21       pgrep looks through the  currently  running  processes  and  lists  the
22       process  IDs  which  matches the selection criteria to stdout.  All the
23       criteria have to match.  For example,
24
25       pgrep -u root sshd
26
27       will only list the processes called sshd AND owned  by  root.   On  the
28       other hand,
29
30       pgrep -u root,daemon
31
32       will list the processes owned by root OR daemon.
33
34       pkill  will  send  the  specified  signal  (by default SIGTERM) to each
35       process instead of listing them on stdout.
36
37

OPTIONS

39       -d delimiter
40              Sets the string used to delimit each process ID  in  the  output
41              (by default a newline).  (pgrep only.)
42
43       -f     The  pattern  is normally only matched against the process name.
44              When -f is set, the full command line is used.
45
46       -g pgrp,...
47              Only match processes in the process group IDs  listed.   Process
48              group 0 is translated into pgrep's or pkill's own process group.
49
50       -G gid,...
51              Only  match processes whose real group ID is listed.  Either the
52              numerical or symbolical value may be used.
53
54       -l     List the process name as well as the process ID. (pgrep only.)
55
56       -n     Select only the newest (most recently started) of  the  matching
57              processes.
58
59       -o     Select  only the oldest (least recently started) of the matching
60              processes.
61
62       -P ppid,...
63              Only match processes whose parent process ID is listed.
64
65       -s sid,...
66              Only match processes whose process session ID is  listed.   Ses‐
67              sion ID 0 is translated into pgrep's or pkill's own session ID.
68
69       -t term,...
70              Only  match processes whose controlling terminal is listed.  The
71              terminal name should be specified without the "/dev/" prefix.
72
73       -u euid,...
74              Only match processes whose effective user ID is listed.   Either
75              the numerical or symbolical value may be used.
76
77       -U uid,...
78              Only  match  processes whose real user ID is listed.  Either the
79              numerical or symbolical value may be used.
80
81       -v     Negates the matching.
82
83       -x     Only match processes whose name (or command line if -f is speci‐
84              fied) exactly match the pattern.
85
86       -signal
87              Defines  the signal to send to each matched process.  Either the
88              numeric or the symbolic signal name can be used.  (pkill only.)
89
90

OPERANDS

92       pattern
93              Specifies an Extended Regular Expression  for  matching  against
94              the process names or command lines.
95
96

EXAMPLES

98       Example 1: Find the process ID of the named daemon:
99
100       unix$ pgrep -u root named
101
102       Example 2: Make syslog reread its configuration file:
103
104       unix$ pkill -HUP syslogd
105
106       Example 3: Give detailed information on all xterm processes:
107
108       unix$ ps -fp $(pgrep -d, -x xterm)
109
110       Example 4: Make all netscape processes run nicer:
111
112       unix$ renice +4 `pgrep netscape`
113
114

EXIT STATUS

116       0      One or more processes matched the criteria.
117
118       1      No processes matched.
119
120       2      Syntax error in the command line.
121
122       3      Fatal error: out of memory etc.
123
124

NOTES

126       The  process  name  used  for  matching is limited to the 15 characters
127       present in the output of /proc/pid/stat.  Use the -f  option  to  match
128       against the complete command line, /proc/pid/cmdline.
129
130       The running pgrep or pkill process will never report itself as a match.
131
132

BUGS

134       The  options  -n and -o and -v can not be combined.  Let me know if you
135       need to do this.
136
137       Defunct processes are reported.
138
139

SEE ALSO

141       ps(1) regex(7) signal(7) killall(1) skill(1) kill(1) kill(2)
142
143

STANDARDS

145       pkill and pgrep were introduced in Sun's Solaris 7.   This  implementa‐
146       tion is fully compatible.
147
148

AUTHOR

150       Kjetil Torgrim Homme <kjetilho@ifi.uio.no>
151
152       Albert  Cahalan  <albert@users.sf.net> is the current maintainer of the
153       procps package.
154
155       Please send bug reports to <procps-feedback@lists.sf.net>
156
157
158
159Linux                            June 25, 2000                        PGREP(1)
Impressum