121be3b31SYaroslav Tykhiy.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ 221be3b31SYaroslav Tykhiy.\" 321be3b31SYaroslav Tykhiy.\" $FreeBSD$ 421be3b31SYaroslav Tykhiy.\" 521be3b31SYaroslav Tykhiy.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 621be3b31SYaroslav Tykhiy.\" All rights reserved. 721be3b31SYaroslav Tykhiy.\" 821be3b31SYaroslav Tykhiy.\" This code is derived from software contributed to The NetBSD Foundation 921be3b31SYaroslav Tykhiy.\" by Andrew Doran. 1021be3b31SYaroslav Tykhiy.\" 1121be3b31SYaroslav Tykhiy.\" Redistribution and use in source and binary forms, with or without 1221be3b31SYaroslav Tykhiy.\" modification, are permitted provided that the following conditions 1321be3b31SYaroslav Tykhiy.\" are met: 1421be3b31SYaroslav Tykhiy.\" 1. Redistributions of source code must retain the above copyright 1521be3b31SYaroslav Tykhiy.\" notice, this list of conditions and the following disclaimer. 1621be3b31SYaroslav Tykhiy.\" 2. Redistributions in binary form must reproduce the above copyright 1721be3b31SYaroslav Tykhiy.\" notice, this list of conditions and the following disclaimer in the 1821be3b31SYaroslav Tykhiy.\" documentation and/or other materials provided with the distribution. 1921be3b31SYaroslav Tykhiy.\" 2021be3b31SYaroslav Tykhiy.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2121be3b31SYaroslav Tykhiy.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2221be3b31SYaroslav Tykhiy.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2321be3b31SYaroslav Tykhiy.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2421be3b31SYaroslav Tykhiy.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2521be3b31SYaroslav Tykhiy.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2621be3b31SYaroslav Tykhiy.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2721be3b31SYaroslav Tykhiy.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2821be3b31SYaroslav Tykhiy.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2921be3b31SYaroslav Tykhiy.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3021be3b31SYaroslav Tykhiy.\" POSSIBILITY OF SUCH DAMAGE. 3121be3b31SYaroslav Tykhiy.\" 32*cc55ad3dSEdward Tomasz Napierala.Dd August 9, 2013 3321be3b31SYaroslav Tykhiy.Dt PKILL 1 3421be3b31SYaroslav Tykhiy.Os 3521be3b31SYaroslav Tykhiy.Sh NAME 3621be3b31SYaroslav Tykhiy.Nm pgrep , pkill 3721be3b31SYaroslav Tykhiy.Nd find or signal processes by name 3821be3b31SYaroslav Tykhiy.Sh SYNOPSIS 3921be3b31SYaroslav Tykhiy.Nm pgrep 407b0706f6SPawel Jakub Dawidek.Op Fl LSafilnoqvx 4121be3b31SYaroslav Tykhiy.Op Fl F Ar pidfile 4221be3b31SYaroslav Tykhiy.Op Fl G Ar gid 4321be3b31SYaroslav Tykhiy.Op Fl M Ar core 4421be3b31SYaroslav Tykhiy.Op Fl N Ar system 4521be3b31SYaroslav Tykhiy.Op Fl P Ar ppid 4621be3b31SYaroslav Tykhiy.Op Fl U Ar uid 47*cc55ad3dSEdward Tomasz Napierala.Op Fl c Ar class 4821be3b31SYaroslav Tykhiy.Op Fl d Ar delim 4921be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 5021be3b31SYaroslav Tykhiy.Op Fl j Ar jid 5121be3b31SYaroslav Tykhiy.Op Fl s Ar sid 5221be3b31SYaroslav Tykhiy.Op Fl t Ar tty 5321be3b31SYaroslav Tykhiy.Op Fl u Ar euid 5421be3b31SYaroslav Tykhiy.Ar pattern ... 5521be3b31SYaroslav Tykhiy.Nm pkill 5621be3b31SYaroslav Tykhiy.Op Fl Ar signal 57b040210dSBrian Somers.Op Fl ILafilnovx 5821be3b31SYaroslav Tykhiy.Op Fl F Ar pidfile 5921be3b31SYaroslav Tykhiy.Op Fl G Ar gid 6021be3b31SYaroslav Tykhiy.Op Fl M Ar core 6121be3b31SYaroslav Tykhiy.Op Fl N Ar system 6221be3b31SYaroslav Tykhiy.Op Fl P Ar ppid 6321be3b31SYaroslav Tykhiy.Op Fl U Ar uid 64*cc55ad3dSEdward Tomasz Napierala.Op Fl c Ar class 6521be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 6621be3b31SYaroslav Tykhiy.Op Fl j Ar jid 6721be3b31SYaroslav Tykhiy.Op Fl s Ar sid 6821be3b31SYaroslav Tykhiy.Op Fl t Ar tty 6921be3b31SYaroslav Tykhiy.Op Fl u Ar euid 7021be3b31SYaroslav Tykhiy.Ar pattern ... 7121be3b31SYaroslav Tykhiy.Sh DESCRIPTION 7221be3b31SYaroslav TykhiyThe 7321be3b31SYaroslav Tykhiy.Nm pgrep 7421be3b31SYaroslav Tykhiycommand searches the process table on the running system and prints the 7521be3b31SYaroslav Tykhiyprocess IDs of all processes that match the criteria given on the command 7621be3b31SYaroslav Tykhiyline. 7721be3b31SYaroslav Tykhiy.Pp 7821be3b31SYaroslav TykhiyThe 7921be3b31SYaroslav Tykhiy.Nm pkill 8021be3b31SYaroslav Tykhiycommand searches the process table on the running system and signals all 8121be3b31SYaroslav Tykhiyprocesses that match the criteria given on the command line. 8221be3b31SYaroslav Tykhiy.Pp 8321be3b31SYaroslav TykhiyThe following options are available: 8421be3b31SYaroslav Tykhiy.Bl -tag -width ".Fl F Ar pidfile" 8521be3b31SYaroslav Tykhiy.It Fl F Ar pidfile 8621be3b31SYaroslav TykhiyRestrict matches to a process whose PID is stored in the 8721be3b31SYaroslav Tykhiy.Ar pidfile 8821be3b31SYaroslav Tykhiyfile. 8921be3b31SYaroslav Tykhiy.It Fl G Ar gid 9021be3b31SYaroslav TykhiyRestrict matches to processes with a real group ID in the comma-separated 9121be3b31SYaroslav Tykhiylist 9221be3b31SYaroslav Tykhiy.Ar gid . 9321be3b31SYaroslav Tykhiy.It Fl I 9421be3b31SYaroslav TykhiyRequest confirmation before attempting to signal each process. 9521be3b31SYaroslav Tykhiy.It Fl L 9621be3b31SYaroslav TykhiyThe 9721be3b31SYaroslav Tykhiy.Ar pidfile 9821be3b31SYaroslav Tykhiyfile given for the 9921be3b31SYaroslav Tykhiy.Fl F 10021be3b31SYaroslav Tykhiyoption must be locked with the 10121be3b31SYaroslav Tykhiy.Xr flock 2 10221be3b31SYaroslav Tykhiysyscall or created with 10321be3b31SYaroslav Tykhiy.Xr pidfile 3 . 10421be3b31SYaroslav Tykhiy.It Fl M Ar core 10521be3b31SYaroslav TykhiyExtract values associated with the name list from the specified core 10621be3b31SYaroslav Tykhiyinstead of the currently running system. 10721be3b31SYaroslav Tykhiy.It Fl N Ar system 10821be3b31SYaroslav TykhiyExtract the name list from the specified system instead of the default, 10921be3b31SYaroslav Tykhiywhich is the kernel image the system has booted from. 11021be3b31SYaroslav Tykhiy.It Fl P Ar ppid 11121be3b31SYaroslav TykhiyRestrict matches to processes with a parent process ID in the 11221be3b31SYaroslav Tykhiycomma-separated list 11321be3b31SYaroslav Tykhiy.Ar ppid . 11421be3b31SYaroslav Tykhiy.It Fl S 11521be3b31SYaroslav TykhiySearch also in system processes (kernel threads). 11621be3b31SYaroslav Tykhiy.It Fl U Ar uid 11721be3b31SYaroslav TykhiyRestrict matches to processes with a real user ID in the comma-separated 11821be3b31SYaroslav Tykhiylist 11921be3b31SYaroslav Tykhiy.Ar uid . 12021be3b31SYaroslav Tykhiy.It Fl d Ar delim 12121be3b31SYaroslav TykhiySpecify a delimiter to be printed between each process ID. 12221be3b31SYaroslav TykhiyThe default is a newline. 12321be3b31SYaroslav TykhiyThis option can only be used with the 12421be3b31SYaroslav Tykhiy.Nm pgrep 12521be3b31SYaroslav Tykhiycommand. 1260a091aebSBrian Somers.It Fl a 1270a091aebSBrian SomersInclude process ancestors in the match list. 1280a091aebSBrian SomersBy default, the current 1290a091aebSBrian Somers.Nm pgrep 1300a091aebSBrian Somersor 1310a091aebSBrian Somers.Nm pkill 1320a091aebSBrian Somersprocess and all of its ancestors are excluded (unless 1330a091aebSBrian Somers.Fl v 1340a091aebSBrian Somersis used). 135*cc55ad3dSEdward Tomasz Napierala.It Fl c Ar class 136*cc55ad3dSEdward Tomasz NapieralaRestrict matches to processes running with specified login class 137*cc55ad3dSEdward Tomasz Napierala.Ar class . 13821be3b31SYaroslav Tykhiy.It Fl f 13921be3b31SYaroslav TykhiyMatch against full argument lists. 14021be3b31SYaroslav TykhiyThe default is to match against process names. 14121be3b31SYaroslav Tykhiy.It Fl g Ar pgrp 14221be3b31SYaroslav TykhiyRestrict matches to processes with a process group ID in the comma-separated 14321be3b31SYaroslav Tykhiylist 14421be3b31SYaroslav Tykhiy.Ar pgrp . 14521be3b31SYaroslav TykhiyThe value zero is taken to mean the process group ID of the running 14621be3b31SYaroslav Tykhiy.Nm pgrep 14721be3b31SYaroslav Tykhiyor 14821be3b31SYaroslav Tykhiy.Nm pkill 14921be3b31SYaroslav Tykhiycommand. 15021be3b31SYaroslav Tykhiy.It Fl i 15121be3b31SYaroslav TykhiyIgnore case distinctions in both the process table and the supplied pattern. 15221be3b31SYaroslav Tykhiy.It Fl j Ar jid 15321be3b31SYaroslav TykhiyRestrict matches to processes inside jails with a jail ID in the comma-separated 15421be3b31SYaroslav Tykhiylist 15521be3b31SYaroslav Tykhiy.Ar jid . 15621be3b31SYaroslav TykhiyThe value 15721be3b31SYaroslav Tykhiy.Dq Li any 15821be3b31SYaroslav Tykhiymatches processes in any jail. 15921be3b31SYaroslav TykhiyThe value 16021be3b31SYaroslav Tykhiy.Dq Li none 16121be3b31SYaroslav Tykhiymatches processes not in jail. 16221be3b31SYaroslav Tykhiy.It Fl l 16321be3b31SYaroslav TykhiyLong output. 1643ba0e470SBrian SomersFor 1653ba0e470SBrian Somers.Nm pgrep , 1663ba0e470SBrian Somersprint the process name in addition to the process ID for each matching 16721be3b31SYaroslav Tykhiyprocess. 16821be3b31SYaroslav TykhiyIf used in conjunction with 16921be3b31SYaroslav Tykhiy.Fl f , 17021be3b31SYaroslav Tykhiyprint the process ID and the full argument list for each matching process. 1713ba0e470SBrian SomersFor 1723ba0e470SBrian Somers.Nm pkill , 1733ba0e470SBrian Somersdisplay the kill command used for each process killed. 17421be3b31SYaroslav Tykhiy.It Fl n 17521be3b31SYaroslav TykhiySelect only the newest (most recently started) of the matching processes. 17621be3b31SYaroslav Tykhiy.It Fl o 17721be3b31SYaroslav TykhiySelect only the oldest (least recently started) of the matching processes. 1787b0706f6SPawel Jakub Dawidek.It Fl q 1797b0706f6SPawel Jakub DawidekDo not write anything to standard output. 18021be3b31SYaroslav Tykhiy.It Fl s Ar sid 18121be3b31SYaroslav TykhiyRestrict matches to processes with a session ID in the comma-separated 18221be3b31SYaroslav Tykhiylist 18321be3b31SYaroslav Tykhiy.Ar sid . 18421be3b31SYaroslav TykhiyThe value zero is taken to mean the session ID of the running 18521be3b31SYaroslav Tykhiy.Nm pgrep 18621be3b31SYaroslav Tykhiyor 18721be3b31SYaroslav Tykhiy.Nm pkill 18821be3b31SYaroslav Tykhiycommand. 18921be3b31SYaroslav Tykhiy.It Fl t Ar tty 19021be3b31SYaroslav TykhiyRestrict matches to processes associated with a terminal in the 19121be3b31SYaroslav Tykhiycomma-separated list 19221be3b31SYaroslav Tykhiy.Ar tty . 19318aa158fSEd SchoutenTerminal names may be of the form 19418aa158fSEd Schouten.Pa tty Ns Ar xx 19518aa158fSEd Schoutenor the shortened form 19618aa158fSEd Schouten.Ar xx . 19721be3b31SYaroslav TykhiyA single dash 19821be3b31SYaroslav Tykhiy.Pq Ql - 19921be3b31SYaroslav Tykhiymatches processes not associated with a terminal. 20021be3b31SYaroslav Tykhiy.It Fl u Ar euid 20121be3b31SYaroslav TykhiyRestrict matches to processes with an effective user ID in the 20221be3b31SYaroslav Tykhiycomma-separated list 20321be3b31SYaroslav Tykhiy.Ar euid . 20421be3b31SYaroslav Tykhiy.It Fl v 20521be3b31SYaroslav TykhiyReverse the sense of the matching; display processes that do not match the 20621be3b31SYaroslav Tykhiygiven criteria. 20721be3b31SYaroslav Tykhiy.It Fl x 20821be3b31SYaroslav TykhiyRequire an exact match of the process name, or argument list if 20921be3b31SYaroslav Tykhiy.Fl f 21021be3b31SYaroslav Tykhiyis given. 21121be3b31SYaroslav TykhiyThe default is to match any substring. 21221be3b31SYaroslav Tykhiy.It Fl Ns Ar signal 21321be3b31SYaroslav TykhiyA non-negative decimal number or symbolic signal name specifying the signal 21421be3b31SYaroslav Tykhiyto be sent instead of the default 21521be3b31SYaroslav Tykhiy.Dv TERM . 21621be3b31SYaroslav TykhiyThis option is valid only when given as the first argument to 21721be3b31SYaroslav Tykhiy.Nm pkill . 21821be3b31SYaroslav Tykhiy.El 21921be3b31SYaroslav Tykhiy.Pp 22021be3b31SYaroslav TykhiyIf any 22121be3b31SYaroslav Tykhiy.Ar pattern 22221be3b31SYaroslav Tykhiyoperands are specified, they are used as regular expressions to match 22321be3b31SYaroslav Tykhiythe command name or full argument list of each process. 22421be3b31SYaroslav TykhiyIf the 22521be3b31SYaroslav Tykhiy.Fl f 22621be3b31SYaroslav Tykhiyoption is not specified, then the 22721be3b31SYaroslav Tykhiy.Ar pattern 22821be3b31SYaroslav Tykhiywill attempt to match the command name. 22921be3b31SYaroslav TykhiyHowever, presently 23021be3b31SYaroslav Tykhiy.Fx 23121be3b31SYaroslav Tykhiywill only keep track of the first 19 characters of the command 23221be3b31SYaroslav Tykhiyname for each process. 23321be3b31SYaroslav TykhiyAttempts to match any characters after the first 19 of a command name 23421be3b31SYaroslav Tykhiywill quietly fail. 23521be3b31SYaroslav Tykhiy.Pp 23621be3b31SYaroslav TykhiyNote that a running 23721be3b31SYaroslav Tykhiy.Nm pgrep 23821be3b31SYaroslav Tykhiyor 23921be3b31SYaroslav Tykhiy.Nm pkill 24021be3b31SYaroslav Tykhiyprocess will never consider itself nor system processes (kernel threads) as 24121be3b31SYaroslav Tykhiya potential match. 24221be3b31SYaroslav Tykhiy.Sh EXIT STATUS 24321be3b31SYaroslav TykhiyThe 24421be3b31SYaroslav Tykhiy.Nm pgrep 24521be3b31SYaroslav Tykhiyand 24621be3b31SYaroslav Tykhiy.Nm pkill 24721be3b31SYaroslav Tykhiyutilities 24821be3b31SYaroslav Tykhiyreturn one of the following values upon exit: 24921be3b31SYaroslav Tykhiy.Bl -tag -width indent 25021be3b31SYaroslav Tykhiy.It 0 25121be3b31SYaroslav TykhiyOne or more processes were matched. 25221be3b31SYaroslav Tykhiy.It 1 25321be3b31SYaroslav TykhiyNo processes were matched. 25421be3b31SYaroslav Tykhiy.It 2 25521be3b31SYaroslav TykhiyInvalid options were specified on the command line. 25621be3b31SYaroslav Tykhiy.It 3 25721be3b31SYaroslav TykhiyAn internal error occurred. 25821be3b31SYaroslav Tykhiy.El 25921be3b31SYaroslav Tykhiy.Sh COMPATIBILITY 26021be3b31SYaroslav TykhiyHistorically the option 26121be3b31SYaroslav Tykhiy.Dq Fl j Li 0 26221be3b31SYaroslav Tykhiymeans any jail, although in other utilities such as 26321be3b31SYaroslav Tykhiy.Xr ps 1 26421be3b31SYaroslav Tykhiyjail ID 26521be3b31SYaroslav Tykhiy.Li 0 26621be3b31SYaroslav Tykhiyhas the opposite meaning, not in jail. 26721be3b31SYaroslav TykhiyTherefore 26821be3b31SYaroslav Tykhiy.Dq Fl j Li 0 26921be3b31SYaroslav Tykhiyis deprecated, and its use is discouraged in favor of 27021be3b31SYaroslav Tykhiy.Dq Fl j Li any . 27121be3b31SYaroslav Tykhiy.Sh SEE ALSO 27221be3b31SYaroslav Tykhiy.Xr kill 1 , 27321be3b31SYaroslav Tykhiy.Xr killall 1 , 27421be3b31SYaroslav Tykhiy.Xr ps 1 , 27521be3b31SYaroslav Tykhiy.Xr flock 2 , 27621be3b31SYaroslav Tykhiy.Xr kill 2 , 27721be3b31SYaroslav Tykhiy.Xr sigaction 2 , 27821be3b31SYaroslav Tykhiy.Xr pidfile 3 , 27921be3b31SYaroslav Tykhiy.Xr re_format 7 28021be3b31SYaroslav Tykhiy.\" Xr signal 7 28121be3b31SYaroslav Tykhiy.Sh HISTORY 28221be3b31SYaroslav TykhiyThe 28321be3b31SYaroslav Tykhiy.Nm pkill 28421be3b31SYaroslav Tykhiyand 28521be3b31SYaroslav Tykhiy.Nm pgrep 28621be3b31SYaroslav Tykhiyutilities 28721be3b31SYaroslav Tykhiyfirst appeared in 28821be3b31SYaroslav Tykhiy.Nx 1.6 . 28921be3b31SYaroslav TykhiyThey are modelled after utilities of the same name that appeared in Sun 29021be3b31SYaroslav TykhiySolaris 7. 29121be3b31SYaroslav TykhiyThey made their first appearance in 29221be3b31SYaroslav Tykhiy.Fx 5.3 . 29321be3b31SYaroslav Tykhiy.Sh AUTHORS 29421be3b31SYaroslav Tykhiy.An Andrew Doran 29521be3b31SYaroslav Tykhiy.Aq ad@NetBSD.org 296