1.\" $OpenBSD: pkill.1,v 1.18 2012/02/09 20:04:35 markus Exp $ 2.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ 3.\" 4.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Andrew Doran. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd $Mdocdate: February 9 2012 $ 32.Dt PKILL 1 33.Os 34.Sh NAME 35.Nm pgrep , pkill 36.Nd find or signal processes by name 37.Sh SYNOPSIS 38.Nm pgrep 39.Op Fl flnovx 40.Op Fl d Ar delim 41.Op Fl G Ar gid 42.Op Fl g Ar pgrp 43.Op Fl P Ar ppid 44.Op Fl s Ar sid 45.Op Fl T Ar rtable 46.Op Fl t Ar tty 47.Op Fl U Ar uid 48.Op Fl u Ar euid 49.Op Ar pattern ... 50.Nm pkill 51.Op Fl Ar signal 52.Op Fl flnovx 53.Op Fl G Ar gid 54.Op Fl g Ar pgrp 55.Op Fl P Ar ppid 56.Op Fl s Ar sid 57.Op Fl T Ar rtable 58.Op Fl t Ar tty 59.Op Fl U Ar uid 60.Op Fl u Ar euid 61.Op Ar pattern ... 62.Sh DESCRIPTION 63The 64.Nm pgrep 65command searches the process table on the running system and prints the 66process IDs of all processes that match the criteria given on the command 67line. 68.Pp 69The 70.Nm pkill 71command searches the process table on the running system and signals all 72processes that match the criteria given on the command line. 73.Pp 74The following options are available: 75.Bl -tag -width Ds 76.It Fl d Ar delim 77Specify a delimiter to be printed between each process ID. 78The default is a newline. 79This option can only be used with the 80.Nm pgrep 81command. 82.It Fl f 83Match against full argument lists. 84The default is to match against process names. 85.It Fl G Ar gid 86Restrict matches to processes with a real group ID in the comma-separated 87list 88.Ar gid . 89.It Fl g Ar pgrp 90Restrict matches to processes with a process group ID in the comma-separated 91list 92.Ar pgrp . 93The value zero is taken to mean the process group ID of the running 94.Nm pgrep 95or 96.Nm pkill 97command. 98.It Fl l 99Long output. 100Print the process name in addition to the process ID for each matching 101process. 102If used in conjunction with 103.Fl f , 104print the process ID and the full argument list for each matching process 105.Pf ( Nm pgrep 106only). 107.It Fl n 108Match only the most recently created (newest) process, if any. 109Cannot be used in conjunction with 110.Fl o . 111.It Fl o 112Match only the least recently created (oldest) process, if any. 113Cannot be used in conjunction with 114.Fl n . 115.It Fl P Ar ppid 116Restrict matches to processes with a parent process ID in the 117comma-separated list 118.Ar ppid . 119.It Fl s Ar sid 120Restrict matches to processes with a session ID in the comma-separated 121list 122.Ar sid . 123The value zero is taken to mean the session ID of the running 124.Nm pgrep 125or 126.Nm pkill 127command. 128.It Fl T Ar rtable 129Restrict matches to processes associated with the specified routing tables 130in the comma-separated list 131.Ar rtable . 132.It Fl t Ar tty 133Restrict matches to processes associated with a terminal in the 134comma-separated list 135.Ar tty . 136Terminal names may be of the form 137.Sq ttyxx 138or the shortened form 139.Sq xx . 140A single dash 141.Pq Sq - 142matches processes not associated with a terminal. 143.It Fl U Ar uid 144Restrict matches to processes with a real user ID in the comma-separated 145list 146.Ar uid . 147.It Fl u Ar euid 148Restrict matches to processes with an effective user ID in the 149comma-separated list 150.Ar euid . 151.It Fl v 152Reverse the sense of the matching; 153display or signal processes that do not match the given criteria. 154.It Fl x 155Require an exact match of the process name, or argument list if 156.Fl f 157is given. 158The default is to match any substring. 159.It Fl Ar signal 160A non-negative decimal number or symbolic signal name specifying the signal 161to be sent instead of the default TERM. 162This option is valid only when given as the first argument to 163.Nm pkill . 164.El 165.Pp 166If any 167.Ar pattern 168operands are specified, they are used as 169regular expressions to match the command name 170or, if 171.Fl f 172is specified, the full argument list of each process. 173However, presently 174.Ox 175will only keep track of the first 16 characters of the command name 176for each process. 177Attempts to match any characters after the first 16 of a 178command name will silently fail. 179.Pp 180Note that a running 181.Nm pgrep 182or 183.Nm pkill 184process will never consider itself or system processes (kernel threads) as 185a potential match. 186.Sh EXIT STATUS 187The 188.Nm pgrep 189and 190.Nm pkill 191utilities exit with one of the following values: 192.Pp 193.Bl -tag -width Ds -offset indent -compact 194.It 0 195One or more processes were matched. 196.It 1 197No processes were matched. 198.It 2 199Invalid options were specified on the command line. 200.It 3 201An internal error occurred. 202.El 203.Sh SEE ALSO 204.Xr grep 1 , 205.Xr kill 1 , 206.Xr ps 1 , 207.Xr kill 2 , 208.Xr sigaction 2 , 209.Xr re_format 7 210.Sh HISTORY 211.Nm pkill 212and 213.Nm pgrep 214first appeared in 215.Ox 3.5 . 216They are modelled after utilities of the same name that appeared in Sun 217Solaris 7. 218.Sh AUTHORS 219.An Andrew Doran 220.Aq ad@NetBSD.org . 221