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.\" 3295880592SSevan Janiyan.Dd December 3, 2018 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 47cc55ad3dSEdward Tomasz Napierala.Op Fl c Ar class 4821be3b31SYaroslav Tykhiy.Op Fl d Ar delim 4921be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 50c4f0631fSJamie Gritton.Op Fl j Ar jail 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 64cc55ad3dSEdward Tomasz Napierala.Op Fl c Ar class 6521be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 66c4f0631fSJamie Gritton.Op Fl j Ar jail 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). 135cc55ad3dSEdward Tomasz Napierala.It Fl c Ar class 136cc55ad3dSEdward Tomasz NapieralaRestrict matches to processes running with specified login class 137cc55ad3dSEdward 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. 152c4f0631fSJamie Gritton.It Fl j Ar jail 153c4f0631fSJamie GrittonRestrict matches to processes inside the specified jails. 154c4f0631fSJamie GrittonThe argument 155c4f0631fSJamie Gritton.Ar jail 156c4f0631fSJamie Grittonmay be 15721be3b31SYaroslav Tykhiy.Dq Li any 158c4f0631fSJamie Grittonto match processes in any jail, 15921be3b31SYaroslav Tykhiy.Dq Li none 160c4f0631fSJamie Grittonto match processes not in jail, 161c4f0631fSJamie Grittonor a comma-separated list of jail IDs or names. 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 179231ad771SBryan DreweryFor 180231ad771SBryan Drewery.Nm pgrep , 1817b0706f6SPawel Jakub DawidekDo not write anything to standard output. 18221be3b31SYaroslav Tykhiy.It Fl s Ar sid 18321be3b31SYaroslav TykhiyRestrict matches to processes with a session ID in the comma-separated 18421be3b31SYaroslav Tykhiylist 18521be3b31SYaroslav Tykhiy.Ar sid . 18621be3b31SYaroslav TykhiyThe value zero is taken to mean the session ID of the running 18721be3b31SYaroslav Tykhiy.Nm pgrep 18821be3b31SYaroslav Tykhiyor 18921be3b31SYaroslav Tykhiy.Nm pkill 19021be3b31SYaroslav Tykhiycommand. 19121be3b31SYaroslav Tykhiy.It Fl t Ar tty 19221be3b31SYaroslav TykhiyRestrict matches to processes associated with a terminal in the 19321be3b31SYaroslav Tykhiycomma-separated list 19421be3b31SYaroslav Tykhiy.Ar tty . 19518aa158fSEd SchoutenTerminal names may be of the form 19618aa158fSEd Schouten.Pa tty Ns Ar xx 19718aa158fSEd Schoutenor the shortened form 19818aa158fSEd Schouten.Ar xx . 19921be3b31SYaroslav TykhiyA single dash 20021be3b31SYaroslav Tykhiy.Pq Ql - 20121be3b31SYaroslav Tykhiymatches processes not associated with a terminal. 20221be3b31SYaroslav Tykhiy.It Fl u Ar euid 20321be3b31SYaroslav TykhiyRestrict matches to processes with an effective user ID in the 20421be3b31SYaroslav Tykhiycomma-separated list 20521be3b31SYaroslav Tykhiy.Ar euid . 20621be3b31SYaroslav Tykhiy.It Fl v 20721be3b31SYaroslav TykhiyReverse the sense of the matching; display processes that do not match the 20821be3b31SYaroslav Tykhiygiven criteria. 20921be3b31SYaroslav Tykhiy.It Fl x 21021be3b31SYaroslav TykhiyRequire an exact match of the process name, or argument list if 21121be3b31SYaroslav Tykhiy.Fl f 21221be3b31SYaroslav Tykhiyis given. 21321be3b31SYaroslav TykhiyThe default is to match any substring. 21421be3b31SYaroslav Tykhiy.It Fl Ns Ar signal 21521be3b31SYaroslav TykhiyA non-negative decimal number or symbolic signal name specifying the signal 21621be3b31SYaroslav Tykhiyto be sent instead of the default 21721be3b31SYaroslav Tykhiy.Dv TERM . 21821be3b31SYaroslav TykhiyThis option is valid only when given as the first argument to 21921be3b31SYaroslav Tykhiy.Nm pkill . 22021be3b31SYaroslav Tykhiy.El 22121be3b31SYaroslav Tykhiy.Pp 22221be3b31SYaroslav TykhiyIf any 22321be3b31SYaroslav Tykhiy.Ar pattern 224e4c7371cSGuangyuan Yangoperands are specified, they are used as extended regular expressions to match 22521be3b31SYaroslav Tykhiythe command name or full argument list of each process. 22621be3b31SYaroslav TykhiyIf the 22721be3b31SYaroslav Tykhiy.Fl f 22821be3b31SYaroslav Tykhiyoption is not specified, then the 22921be3b31SYaroslav Tykhiy.Ar pattern 23021be3b31SYaroslav Tykhiywill attempt to match the command name. 23121be3b31SYaroslav TykhiyHowever, presently 23221be3b31SYaroslav Tykhiy.Fx 23321be3b31SYaroslav Tykhiywill only keep track of the first 19 characters of the command 23421be3b31SYaroslav Tykhiyname for each process. 23521be3b31SYaroslav TykhiyAttempts to match any characters after the first 19 of a command name 23621be3b31SYaroslav Tykhiywill quietly fail. 23721be3b31SYaroslav Tykhiy.Pp 23821be3b31SYaroslav TykhiyNote that a running 23921be3b31SYaroslav Tykhiy.Nm pgrep 24021be3b31SYaroslav Tykhiyor 24121be3b31SYaroslav Tykhiy.Nm pkill 24221be3b31SYaroslav Tykhiyprocess will never consider itself nor system processes (kernel threads) as 24321be3b31SYaroslav Tykhiya potential match. 24495880592SSevan Janiyan.Sh IMPLEMENTATION NOTES 24595880592SSevan JaniyanThe Sun Solaris implementation utilised procfs to obtain process information. 24695880592SSevan JaniyanThis implementation utilises 24795880592SSevan Janiyan.Xr kvm 3 24895880592SSevan Janiyaninstead. 249*d7a57037SSevan JaniyanOn a live system, 250*d7a57037SSevan Janiyan.Xr kvm 3 251*d7a57037SSevan Janiyanuses 252*d7a57037SSevan Janiyan.Va kern.proc 253*d7a57037SSevan JaniyanMIB to obtain the list of processes, kernel memory through 254*d7a57037SSevan Janiyan.Pa /dev/kmem 255*d7a57037SSevan Janiyanis not accessed. 25621be3b31SYaroslav Tykhiy.Sh EXIT STATUS 25721be3b31SYaroslav TykhiyThe 25821be3b31SYaroslav Tykhiy.Nm pgrep 25921be3b31SYaroslav Tykhiyand 26021be3b31SYaroslav Tykhiy.Nm pkill 26121be3b31SYaroslav Tykhiyutilities 26221be3b31SYaroslav Tykhiyreturn one of the following values upon exit: 26321be3b31SYaroslav Tykhiy.Bl -tag -width indent 26421be3b31SYaroslav Tykhiy.It 0 26521be3b31SYaroslav TykhiyOne or more processes were matched. 26621be3b31SYaroslav Tykhiy.It 1 26721be3b31SYaroslav TykhiyNo processes were matched. 26821be3b31SYaroslav Tykhiy.It 2 26921be3b31SYaroslav TykhiyInvalid options were specified on the command line. 27021be3b31SYaroslav Tykhiy.It 3 27121be3b31SYaroslav TykhiyAn internal error occurred. 27221be3b31SYaroslav Tykhiy.El 27321be3b31SYaroslav Tykhiy.Sh COMPATIBILITY 27421be3b31SYaroslav TykhiyHistorically the option 27521be3b31SYaroslav Tykhiy.Dq Fl j Li 0 27621be3b31SYaroslav Tykhiymeans any jail, although in other utilities such as 27721be3b31SYaroslav Tykhiy.Xr ps 1 27821be3b31SYaroslav Tykhiyjail ID 27921be3b31SYaroslav Tykhiy.Li 0 28021be3b31SYaroslav Tykhiyhas the opposite meaning, not in jail. 28121be3b31SYaroslav TykhiyTherefore 28221be3b31SYaroslav Tykhiy.Dq Fl j Li 0 28321be3b31SYaroslav Tykhiyis deprecated, and its use is discouraged in favor of 28421be3b31SYaroslav Tykhiy.Dq Fl j Li any . 28521be3b31SYaroslav Tykhiy.Sh SEE ALSO 28621be3b31SYaroslav Tykhiy.Xr kill 1 , 28721be3b31SYaroslav Tykhiy.Xr killall 1 , 28821be3b31SYaroslav Tykhiy.Xr ps 1 , 28921be3b31SYaroslav Tykhiy.Xr flock 2 , 29021be3b31SYaroslav Tykhiy.Xr kill 2 , 29121be3b31SYaroslav Tykhiy.Xr sigaction 2 , 292*d7a57037SSevan Janiyan.Xr kvm 3 , 29321be3b31SYaroslav Tykhiy.Xr pidfile 3 , 29421be3b31SYaroslav Tykhiy.Xr re_format 7 29521be3b31SYaroslav Tykhiy.\" Xr signal 7 29621be3b31SYaroslav Tykhiy.Sh HISTORY 29721be3b31SYaroslav TykhiyThe 29821be3b31SYaroslav Tykhiy.Nm pkill 29921be3b31SYaroslav Tykhiyand 30021be3b31SYaroslav Tykhiy.Nm pgrep 30121be3b31SYaroslav Tykhiyutilities 30221be3b31SYaroslav Tykhiyfirst appeared in 30321be3b31SYaroslav Tykhiy.Nx 1.6 . 30421be3b31SYaroslav TykhiyThey are modelled after utilities of the same name that appeared in Sun 30521be3b31SYaroslav TykhiySolaris 7. 30621be3b31SYaroslav TykhiyThey made their first appearance in 30721be3b31SYaroslav Tykhiy.Fx 5.3 . 30821be3b31SYaroslav Tykhiy.Sh AUTHORS 309bd0891ceSBaptiste Daroussin.An Andrew Doran Aq Mt ad@NetBSD.org 310