]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - usr.bin/pkill/pkill.1
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / usr.bin / pkill / pkill.1
1 .\"     $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $
2 .\"
3 .\" $FreeBSD$
4 .\"
5 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
6 .\" All rights reserved.
7 .\"
8 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" by Andrew Doran.
10 .\"
11 .\" Redistribution and use in source and binary forms, with or without
12 .\" modification, are permitted provided that the following conditions
13 .\" are met:
14 .\" 1. Redistributions of source code must retain the above copyright
15 .\"    notice, this list of conditions and the following disclaimer.
16 .\" 2. Redistributions in binary form must reproduce the above copyright
17 .\"    notice, this list of conditions and the following disclaimer in the
18 .\"    documentation and/or other materials provided with the distribution.
19 .\" 3. All advertising materials mentioning features or use of this software
20 .\"    must display the following acknowledgement:
21 .\"        This product includes software developed by the NetBSD
22 .\"        Foundation, Inc. and its contributors.
23 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
24 .\"    contributors may be used to endorse or promote products derived
25 .\"    from this software without specific prior written permission.
26 .\"
27 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 .\" POSSIBILITY OF SUCH DAMAGE.
38 .\"
39 .Dd November 23, 2006
40 .Dt PKILL 1
41 .Os
42 .Sh NAME
43 .Nm pgrep , pkill
44 .Nd find or signal processes by name
45 .Sh SYNOPSIS
46 .Nm pgrep
47 .Op Fl LSfilnovx
48 .Op Fl F Ar pidfile
49 .Op Fl G Ar gid
50 .Op Fl M Ar core
51 .Op Fl N Ar system
52 .Op Fl P Ar ppid
53 .Op Fl U Ar uid
54 .Op Fl d Ar delim
55 .Op Fl g Ar pgrp
56 .Op Fl j Ar jid
57 .Op Fl s Ar sid
58 .Op Fl t Ar tty
59 .Op Fl u Ar euid
60 .Ar pattern ...
61 .Nm pkill
62 .Op Fl Ar signal
63 .Op Fl ILfinovx
64 .Op Fl F Ar pidfile
65 .Op Fl G Ar gid
66 .Op Fl M Ar core
67 .Op Fl N Ar system
68 .Op Fl P Ar ppid
69 .Op Fl U Ar uid
70 .Op Fl g Ar pgrp
71 .Op Fl j Ar jid
72 .Op Fl s Ar sid
73 .Op Fl t Ar tty
74 .Op Fl u Ar euid
75 .Ar pattern ...
76 .Sh DESCRIPTION
77 The
78 .Nm pgrep
79 command searches the process table on the running system and prints the
80 process IDs of all processes that match the criteria given on the command
81 line.
82 .Pp
83 The
84 .Nm pkill
85 command searches the process table on the running system and signals all
86 processes that match the criteria given on the command line.
87 .Pp
88 The following options are available:
89 .Bl -tag -width ".Fl F Ar pidfile"
90 .It Fl F Ar pidfile
91 Restrict matches to a process whose PID is stored in the
92 .Ar pidfile
93 file.
94 .It Fl G Ar gid
95 Restrict matches to processes with a real group ID in the comma-separated
96 list
97 .Ar gid .
98 .It Fl I
99 Request confirmation before attempting to signal each process.
100 .It Fl L
101 The
102 .Ar pidfile
103 file given for the
104 .Fl F
105 option must be locked with the
106 .Xr flock 2
107 syscall or created with
108 .Xr pidfile 3 .
109 .It Fl M Ar core
110 Extract values associated with the name list from the specified core
111 instead of the currently running system.
112 .It Fl N Ar system
113 Extract the name list from the specified system instead of the default,
114 which is the kernel image the system has booted from.
115 .It Fl P Ar ppid
116 Restrict matches to processes with a parent process ID in the
117 comma-separated list
118 .Ar ppid .
119 .It Fl S
120 Search also in system processes (kernel threads).
121 .It Fl U Ar uid
122 Restrict matches to processes with a real user ID in the comma-separated
123 list
124 .Ar uid .
125 .It Fl d Ar delim
126 Specify a delimiter to be printed between each process ID.
127 The default is a newline.
128 This option can only be used with the
129 .Nm pgrep
130 command.
131 .It Fl f
132 Match against full argument lists.
133 The default is to match against process names.
134 .It Fl g Ar pgrp
135 Restrict matches to processes with a process group ID in the comma-separated
136 list
137 .Ar pgrp .
138 The value zero is taken to mean the process group ID of the running
139 .Nm pgrep
140 or
141 .Nm pkill
142 command.
143 .It Fl i
144 Ignore case distinctions in both the process table and the supplied pattern.
145 .It Fl j Ar jid
146 Restrict matches to processes inside jails with a jail ID in the comma-separated
147 list
148 .Ar jid .
149 The value
150 .Dq Li any
151 matches processes in any jail.
152 The value
153 .Dq Li none
154 matches processes not in jail.
155 .It Fl l
156 Long output.
157 Print the process name in addition to the process ID for each matching
158 process.
159 If used in conjunction with
160 .Fl f ,
161 print the process ID and the full argument list for each matching process.
162 This option can only be used with the
163 .Nm pgrep
164 command.
165 .It Fl n
166 Select only the newest (most recently started) of the matching processes.
167 .It Fl o
168 Select only the oldest (least recently started) of the matching processes.
169 .It Fl s Ar sid
170 Restrict matches to processes with a session ID in the comma-separated
171 list
172 .Ar sid .
173 The value zero is taken to mean the session ID of the running
174 .Nm pgrep
175 or
176 .Nm pkill
177 command.
178 .It Fl t Ar tty
179 Restrict matches to processes associated with a terminal in the
180 comma-separated list
181 .Ar tty .
182 Terminal names may be of the form
183 .Pa tty Ns Ar xx
184 or the shortened form
185 .Ar xx .
186 A single dash
187 .Pq Ql -
188 matches processes not associated with a terminal.
189 .It Fl u Ar euid
190 Restrict matches to processes with an effective user ID in the
191 comma-separated list
192 .Ar euid .
193 .It Fl v
194 Reverse the sense of the matching; display processes that do not match the
195 given criteria.
196 .It Fl x
197 Require an exact match of the process name, or argument list if
198 .Fl f
199 is given.
200 The default is to match any substring.
201 .It Fl Ns Ar signal
202 A non-negative decimal number or symbolic signal name specifying the signal
203 to be sent instead of the default
204 .Dv TERM .
205 This option is valid only when given as the first argument to
206 .Nm pkill .
207 .El
208 .Pp
209 If any
210 .Ar pattern
211 operands are specified, they are used as regular expressions to match
212 the command name or full argument list of each process.
213 If the
214 .Fl f
215 option is not specified, then the
216 .Ar pattern
217 will attempt to match the command name.
218 However, presently
219 .Fx
220 will only keep track of the first 19 characters of the command
221 name for each process.
222 Attempts to match any characters after the first 19 of a command name
223 will quietly fail.
224 .Pp
225 Note that a running
226 .Nm pgrep
227 or
228 .Nm pkill
229 process will never consider itself nor system processes (kernel threads) as
230 a potential match.
231 .Sh EXIT STATUS
232 The
233 .Nm pgrep
234 and
235 .Nm pkill
236 utilities
237 return one of the following values upon exit:
238 .Bl -tag -width indent
239 .It 0
240 One or more processes were matched.
241 .It 1
242 No processes were matched.
243 .It 2
244 Invalid options were specified on the command line.
245 .It 3
246 An internal error occurred.
247 .El
248 .Sh COMPATIBILITY
249 Historically the option
250 .Dq Fl j Li 0
251 means any jail, although in other utilities such as
252 .Xr ps 1
253 jail ID
254 .Li 0
255 has the opposite meaning, not in jail.
256 Therefore
257 .Dq Fl j Li 0
258 is deprecated, and its use is discouraged in favor of
259 .Dq Fl j Li any .
260 .Sh SEE ALSO
261 .Xr kill 1 ,
262 .Xr killall 1 ,
263 .Xr ps 1 ,
264 .Xr flock 2 ,
265 .Xr kill 2 ,
266 .Xr sigaction 2 ,
267 .Xr pidfile 3 ,
268 .Xr re_format 7
269 .\" Xr signal 7
270 .Sh HISTORY
271 The
272 .Nm pkill
273 and
274 .Nm pgrep
275 utilities
276 first appeared in
277 .Nx 1.6 .
278 They are modelled after utilities of the same name that appeared in Sun
279 Solaris 7.
280 They made their first appearance in
281 .Fx 5.3 .
282 .Sh AUTHORS
283 .An Andrew Doran
284 .Aq ad@NetBSD.org