1*70ef51b6Sotto.\" $OpenBSD: pkill.1,v 1.25 2020/11/14 14:06:42 otto Exp $ 245580423Smillert.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ 345580423Smillert.\" 445580423Smillert.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 545580423Smillert.\" All rights reserved. 645580423Smillert.\" 745580423Smillert.\" This code is derived from software contributed to The NetBSD Foundation 845580423Smillert.\" by Andrew Doran. 945580423Smillert.\" 1045580423Smillert.\" Redistribution and use in source and binary forms, with or without 1145580423Smillert.\" modification, are permitted provided that the following conditions 1245580423Smillert.\" are met: 1345580423Smillert.\" 1. Redistributions of source code must retain the above copyright 1445580423Smillert.\" notice, this list of conditions and the following disclaimer. 1545580423Smillert.\" 2. Redistributions in binary form must reproduce the above copyright 1645580423Smillert.\" notice, this list of conditions and the following disclaimer in the 1745580423Smillert.\" documentation and/or other materials provided with the distribution. 1845580423Smillert.\" 1945580423Smillert.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2045580423Smillert.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2145580423Smillert.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2245580423Smillert.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2345580423Smillert.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2445580423Smillert.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2545580423Smillert.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2645580423Smillert.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2745580423Smillert.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2845580423Smillert.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2945580423Smillert.\" POSSIBILITY OF SUCH DAMAGE. 3045580423Smillert.\" 31*70ef51b6Sotto.Dd $Mdocdate: November 14 2020 $ 3245580423Smillert.Dt PKILL 1 3345580423Smillert.Os 3445580423Smillert.Sh NAME 35f44215f1Sjmc.Nm pgrep , pkill 3645580423Smillert.Nd find or signal processes by name 3745580423Smillert.Sh SYNOPSIS 3845580423Smillert.Nm pgrep 39d2e6cab4Sespie.Op Fl flnoqvx 4045580423Smillert.Op Fl d Ar delim 410ecd6060Sjmc.Op Fl G Ar gid 4245580423Smillert.Op Fl g Ar pgrp 430ecd6060Sjmc.Op Fl P Ar ppid 4445580423Smillert.Op Fl s Ar sid 451b2463c8Smarkus.Op Fl T Ar rtable 4645580423Smillert.Op Fl t Ar tty 470ecd6060Sjmc.Op Fl U Ar uid 4845580423Smillert.Op Fl u Ar euid 490ecd6060Sjmc.Op Ar pattern ... 5045580423Smillert.Nm pkill 5104c2b29cSjmc.Op Fl Ar signal 52e880abb2Stedu.Op Fl fIlnoqvx 5345580423Smillert.Op Fl G Ar gid 5445580423Smillert.Op Fl g Ar pgrp 550ecd6060Sjmc.Op Fl P Ar ppid 5645580423Smillert.Op Fl s Ar sid 571b2463c8Smarkus.Op Fl T Ar rtable 5845580423Smillert.Op Fl t Ar tty 590ecd6060Sjmc.Op Fl U Ar uid 6045580423Smillert.Op Fl u Ar euid 610ecd6060Sjmc.Op Ar pattern ... 6245580423Smillert.Sh DESCRIPTION 6345580423SmillertThe 6445580423Smillert.Nm pgrep 6545580423Smillertcommand searches the process table on the running system and prints the 6645580423Smillertprocess IDs of all processes that match the criteria given on the command 6745580423Smillertline. 6845580423Smillert.Pp 6945580423SmillertThe 7045580423Smillert.Nm pkill 7145580423Smillertcommand searches the process table on the running system and signals all 7245580423Smillertprocesses that match the criteria given on the command line. 7345580423Smillert.Pp 7445580423SmillertThe following options are available: 7568d016f5Sjmc.Bl -tag -width Ds 7645580423Smillert.It Fl d Ar delim 7745580423SmillertSpecify a delimiter to be printed between each process ID. 7845580423SmillertThe default is a newline. 7945580423SmillertThis option can only be used with the 8045580423Smillert.Nm pgrep 8145580423Smillertcommand. 8245580423Smillert.It Fl f 8345580423SmillertMatch against full argument lists. 8445580423SmillertThe default is to match against process names. 850ecd6060Sjmc.It Fl G Ar gid 860ecd6060SjmcRestrict matches to processes with a real group ID in the comma-separated 870ecd6060Sjmclist 880ecd6060Sjmc.Ar gid . 8945580423Smillert.It Fl g Ar pgrp 9045580423SmillertRestrict matches to processes with a process group ID in the comma-separated 9145580423Smillertlist 9245580423Smillert.Ar pgrp . 9345580423SmillertThe value zero is taken to mean the process group ID of the running 9445580423Smillert.Nm pgrep 9545580423Smillertor 9645580423Smillert.Nm pkill 9745580423Smillertcommand. 985123b6b9Sjmc.It Fl I 995123b6b9SjmcAsk for confirmation before killing a process. 10045580423Smillert.It Fl l 10145580423SmillertLong output. 10245580423SmillertPrint the process name in addition to the process ID for each matching 10345580423Smillertprocess. 10445580423SmillertIf used in conjunction with 10545580423Smillert.Fl f , 1060475d536Slumprint the process ID and the full argument list for each matching process 1070475d536Slum.Pf ( Nm pgrep 1080475d536Slumonly). 10945580423Smillert.It Fl n 11083d16d5cSmillertMatch only the most recently created (newest) process, if any. 111b58b9ed4SsobradoCannot be used in conjunction with 11283d16d5cSmillert.Fl o . 11383d16d5cSmillert.It Fl o 11483d16d5cSmillertMatch only the least recently created (oldest) process, if any. 115b58b9ed4SsobradoCannot be used in conjunction with 11683d16d5cSmillert.Fl n . 1170ecd6060Sjmc.It Fl P Ar ppid 1180ecd6060SjmcRestrict matches to processes with a parent process ID in the 1190ecd6060Sjmccomma-separated list 1200ecd6060Sjmc.Ar ppid . 1211bce3d6cSajacoutot.It Fl q 1221bce3d6cSajacoutotQuiet mode. 1231bce3d6cSajacoutotPerform the action, but don't display anything on standard output. 1241bce3d6cSajacoutotNote that 1251bce3d6cSajacoutot.Fl q 1261bce3d6cSajacoutottakes precedence over other display options such as 1271bce3d6cSajacoutot.Fl l . 12845580423Smillert.It Fl s Ar sid 12945580423SmillertRestrict matches to processes with a session ID in the comma-separated 13045580423Smillertlist 13145580423Smillert.Ar sid . 13245580423SmillertThe value zero is taken to mean the session ID of the running 13345580423Smillert.Nm pgrep 13445580423Smillertor 13545580423Smillert.Nm pkill 13645580423Smillertcommand. 1371b2463c8Smarkus.It Fl T Ar rtable 1381b2463c8SmarkusRestrict matches to processes associated with the specified routing tables 1391b2463c8Smarkusin the comma-separated list 1401b2463c8Smarkus.Ar rtable . 14145580423Smillert.It Fl t Ar tty 14245580423SmillertRestrict matches to processes associated with a terminal in the 14345580423Smillertcomma-separated list 14445580423Smillert.Ar tty . 14545580423SmillertTerminal names may be of the form 14645580423Smillert.Sq ttyxx 14745580423Smillertor the shortened form 14845580423Smillert.Sq xx . 14968d016f5SjmcA single dash 15068d016f5Sjmc.Pq Sq - 15168d016f5Sjmcmatches processes not associated with a terminal. 1520ecd6060Sjmc.It Fl U Ar uid 1530ecd6060SjmcRestrict matches to processes with a real user ID in the comma-separated 1540ecd6060Sjmclist 1550ecd6060Sjmc.Ar uid . 15645580423Smillert.It Fl u Ar euid 15745580423SmillertRestrict matches to processes with an effective user ID in the 15845580423Smillertcomma-separated list 15945580423Smillert.Ar euid . 16045580423Smillert.It Fl v 16119494124SjmcReverse the sense of the matching; 16219494124Sjmcdisplay or signal processes that do not match the given criteria. 16345580423Smillert.It Fl x 16445580423SmillertRequire an exact match of the process name, or argument list if 16545580423Smillert.Fl f 16645580423Smillertis given. 16745580423SmillertThe default is to match any substring. 16804c2b29cSjmc.It Fl Ar signal 16945580423SmillertA non-negative decimal number or symbolic signal name specifying the signal 17045580423Smillertto be sent instead of the default TERM. 17145580423SmillertThis option is valid only when given as the first argument to 17245580423Smillert.Nm pkill . 17345580423Smillert.El 17445580423Smillert.Pp 175734e1cd6SjmcIf any 176734e1cd6Sjmc.Ar pattern 177*70ef51b6Sottooperands are specified, 178*70ef51b6Sottothey are used as extended regular expressions to match the command name. 179*70ef51b6SottoOnly the first 16 characters of the command name are matched; 180*70ef51b6Sottoattempts to match any characters after the first 16 will silently fail. 181*70ef51b6SottoIf 182734e1cd6Sjmc.Fl f 183*70ef51b6Sottois specified, the full argument list, 184*70ef51b6Sottoincluding the full command name, 185*70ef51b6Sottoof each process is matched. 186734e1cd6Sjmc.Pp 18745580423SmillertNote that a running 18845580423Smillert.Nm pgrep 18945580423Smillertor 19045580423Smillert.Nm pkill 19168d016f5Sjmcprocess will never consider itself or system processes (kernel threads) as 19245580423Smillerta potential match. 19311c0d3b3Sjmc.Sh EXIT STATUS 19411c0d3b3SjmcThe 19545580423Smillert.Nm pgrep 19645580423Smillertand 19745580423Smillert.Nm pkill 19811c0d3b3Sjmcutilities exit with one of the following values: 19968d016f5Sjmc.Pp 20068d016f5Sjmc.Bl -tag -width Ds -offset indent -compact 20145580423Smillert.It 0 20245580423SmillertOne or more processes were matched. 20345580423Smillert.It 1 20445580423SmillertNo processes were matched. 20545580423Smillert.It 2 20645580423SmillertInvalid options were specified on the command line. 20745580423Smillert.It 3 20845580423SmillertAn internal error occurred. 20945580423Smillert.El 21045580423Smillert.Sh SEE ALSO 21168d016f5Sjmc.Xr grep 1 , 21245580423Smillert.Xr kill 1 , 21345580423Smillert.Xr ps 1 , 21445580423Smillert.Xr kill 2 , 21545580423Smillert.Xr sigaction 2 , 2168db73b0fSmillert.Xr re_format 7 21745580423Smillert.Sh HISTORY 21845580423Smillert.Nm pkill 21945580423Smillertand 22045580423Smillert.Nm pgrep 22145580423Smillertfirst appeared in 22245580423Smillert.Ox 3.5 . 22345580423SmillertThey are modelled after utilities of the same name that appeared in Sun 22445580423SmillertSolaris 7. 22545580423Smillert.Sh AUTHORS 22645580423Smillert.An Andrew Doran 22776c04420Sschwarze.Aq Mt ad@NetBSD.org . 228