version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
PGREP |
|
|
2 |
!!!PGREP |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
OPTIONS |
|
|
7 |
OPERANDS |
|
|
8 |
EXAMPLES |
|
|
9 |
EXIT STATUS |
|
|
10 |
NOTES |
|
|
11 |
BUGS |
|
|
12 |
SEE ALSO |
|
|
13 |
STANDARDS |
|
|
14 |
AUTHOR |
|
|
15 |
---- |
|
|
16 |
!!NAME |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
pgrep, pkill - look up or signal processes based on name and other attributes |
|
|
20 |
!!SYNOPSIS |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
pgrep [[-flnvx] [[-d ''delimiter''] [[-P ''ppid'',...] |
|
|
24 |
[[-g ''pgrp'',...] |
|
|
25 |
[[-s ''sid'',...] [[-u ''euid'',...] [[-U ''uid'',...] |
|
|
26 |
[[-G ''gid'',...] |
|
|
27 |
[[-t ''term'',...] [[''pattern''] |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
pkill [[-''signal''] [[-fnvx] [[-P ''ppid'',...] [[-g |
|
|
31 |
''pgrp'',...] |
|
|
32 |
[[-s ''sid'',...] [[-u ''euid'',...] [[-U ''uid'',...] |
|
|
33 |
[[-G ''gid'',...] |
|
|
34 |
[[-t ''term'',...] [[''pattern''] |
|
|
35 |
!!DESCRIPTION |
|
|
36 |
|
|
|
37 |
|
|
|
38 |
__pgrep__ looks through the currently running processes |
|
|
39 |
and lists the process IDs which matches the selection |
|
|
40 |
criteria to stdout. All the criteria have to match. For |
|
|
41 |
example, |
|
|
42 |
|
|
|
43 |
|
|
|
44 |
pgrep -u root sshd |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
will only list the processes called __sshd__ AND owned by |
|
|
48 |
__root__. On the other hand, |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
pgrep -u root,daemon |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
will list the processes owned by __root__ OR |
|
|
55 |
__daemon__. |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
__pkill__ will send the specified signal (by default |
|
|
59 |
__SIGTERM__) to each process instead of listing them on |
|
|
60 |
stdout. |
|
|
61 |
!!OPTIONS |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
-d ''delimiter'' |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
Sets the string used to delimit each process ID in the |
|
|
68 |
output (by default a newline). (__pgrep__ |
|
|
69 |
only.) |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
-f |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
The ''pattern'' is normally only matched against the |
|
|
76 |
process name. When -f is set, the full command line is |
|
|
77 |
used. |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
-g ''pgrp'',... |
|
|
81 |
|
|
|
82 |
|
|
|
83 |
Only match processes in the process group IDs listed. |
|
|
84 |
Process group 0 is translated into __pgrep__'s or |
|
|
85 |
__pkill__'s own process group. |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
-G ''gid'',... |
|
|
89 |
|
|
|
90 |
|
|
|
91 |
Only match processes whose real group ID is listed. Either |
|
|
92 |
the numerical or symbolical value may be used. |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
-l |
|
|
96 |
|
|
|
97 |
|
|
|
98 |
List the process name as well as the process ID. |
|
|
99 |
(__pgrep__ only.) |
|
|
100 |
|
|
|
101 |
|
|
|
102 |
-n |
|
|
103 |
|
|
|
104 |
|
|
|
105 |
Select only the newest (most recently started) of the |
|
|
106 |
matching processes. |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
-P ''ppid'',... |
|
|
110 |
|
|
|
111 |
|
|
|
112 |
Only match processes whose parent process ID is |
|
|
113 |
listed. |
|
|
114 |
|
|
|
115 |
|
|
|
116 |
-s ''sid'',... |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
Only match processes whose process session ID is listed. |
|
|
120 |
Session ID 0 is translated into __pgrep__'s or |
|
|
121 |
__pkill__'s own session ID. |
|
|
122 |
|
|
|
123 |
|
|
|
124 |
-t ''term'',... |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
Only match processes whose controlling terminal is listed. |
|
|
128 |
The terminal name should be specified without the |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
-u ''euid'',... |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
Only match processes whose effective user ID is listed. |
|
|
135 |
Either the numerical or symbolical value may be |
|
|
136 |
used. |
|
|
137 |
|
|
|
138 |
|
|
|
139 |
-U ''uid'',... |
|
|
140 |
|
|
|
141 |
|
|
|
142 |
Only match processes whose real user ID is listed. Either |
|
|
143 |
the numerical or symbolical value may be used. |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
-v |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
Negates the matching. |
|
|
150 |
|
|
|
151 |
|
|
|
152 |
-x |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
Only match processes whose name (or command line if -f is |
|
|
156 |
specified) __exactly__ match the |
|
|
157 |
''pattern''. |
|
|
158 |
|
|
|
159 |
|
|
|
160 |
-''signal'' |
|
|
161 |
|
|
|
162 |
|
|
|
163 |
Defines the signal to send to each matched process. Either |
|
|
164 |
the numeric or the symbolic signal name can be used. |
|
|
165 |
(__pkill__ only.) |
|
|
166 |
!!OPERANDS |
|
|
167 |
|
|
|
168 |
|
|
|
169 |
''pattern'' |
|
|
170 |
|
|
|
171 |
|
|
|
172 |
Specifies an Extended Regular Expression for matching |
|
|
173 |
against the process names or command lines. |
|
|
174 |
!!EXAMPLES |
|
|
175 |
|
|
|
176 |
|
|
|
177 |
Example 1: Find the process ID of the __named__ |
|
|
178 |
daemon: |
|
|
179 |
|
|
|
180 |
|
|
|
181 |
unix$ pgrep -u root named |
|
|
182 |
|
|
|
183 |
|
|
|
184 |
Example 2: Make __syslog__ reread its configuration |
|
|
185 |
file: |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
unix$ pkill -HUP syslogd |
|
|
189 |
|
|
|
190 |
|
|
|
191 |
Example 3: Give detailed information on all __xterm__ |
|
|
192 |
processes: |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
unix$ ps -fp $(pgrep -d, -x xterm) |
|
|
196 |
|
|
|
197 |
|
|
|
198 |
Example 4: Make all __netscape__ processes run |
|
|
199 |
nicer: |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
unix$ renice +4 `pgrep netscape` |
|
|
203 |
!!EXIT STATUS |
|
|
204 |
|
|
|
205 |
|
|
|
206 |
''0'' |
|
|
207 |
|
|
|
208 |
|
|
|
209 |
One or more processes matched the criteria. |
|
|
210 |
|
|
|
211 |
|
|
|
212 |
''1'' |
|
|
213 |
|
|
|
214 |
|
|
|
215 |
No processes matched. |
|
|
216 |
|
|
|
217 |
|
|
|
218 |
''2'' |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
Syntax error in the command line. |
|
|
222 |
|
|
|
223 |
|
|
|
224 |
''3'' |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
Fatal error: out of memory etc. |
|
|
228 |
!!NOTES |
|
|
229 |
|
|
|
230 |
|
|
|
231 |
The process name used for matching is limited to the 15 |
|
|
232 |
characters present in the output of /proc/''pid''/stat. |
|
|
233 |
Use the -f option to match against the complete command |
|
|
234 |
line, /proc/''pid''/cmdline. |
|
|
235 |
|
|
|
236 |
|
|
|
237 |
The running __pgrep__ or __pkill__ process will never |
|
|
238 |
report itself as a match. |
|
|
239 |
!!BUGS |
|
|
240 |
|
|
|
241 |
|
|
|
242 |
The options -n and -v can not be combined. Let me know if |
|
|
243 |
you need to do this. |
|
|
244 |
|
|
|
245 |
|
|
|
246 |
Defunct processes are reported. |
|
|
247 |
!!SEE ALSO |
|
|
248 |
|
|
|
249 |
|
|
|
250 |
ps(1) proc(5) regex(5) |
|
|
251 |
!!STANDARDS |
|
|
252 |
|
|
|
253 |
|
|
|
254 |
__pkill__ and __pgrep__ were introduced in Sun's |
|
|
255 |
Solaris 7. This implementation is fully |
|
|
256 |
compatible. |
|
|
257 |
!!AUTHOR |
|
|
258 |
|
|
|
259 |
|
|
|
260 |
Kjetil Torgrim Homme |
|
|
261 |
|
|
|
262 |
|
|
|
263 |
Michael K. Johnson |
|
|
264 |
|
|
|
265 |
|
|
|
266 |
Please send bug reports to |
|
|
267 |
---- |