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.\" 327b0706f6SPawel Jakub Dawidek.Dd February 11, 2010 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 4721be3b31SYaroslav Tykhiy.Op Fl d Ar delim 4821be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 4921be3b31SYaroslav Tykhiy.Op Fl j Ar jid 5021be3b31SYaroslav Tykhiy.Op Fl s Ar sid 5121be3b31SYaroslav Tykhiy.Op Fl t Ar tty 5221be3b31SYaroslav Tykhiy.Op Fl u Ar euid 5321be3b31SYaroslav Tykhiy.Ar pattern ... 5421be3b31SYaroslav Tykhiy.Nm pkill 5521be3b31SYaroslav Tykhiy.Op Fl Ar signal 56*b040210dSBrian Somers.Op Fl ILafilnovx 5721be3b31SYaroslav Tykhiy.Op Fl F Ar pidfile 5821be3b31SYaroslav Tykhiy.Op Fl G Ar gid 5921be3b31SYaroslav Tykhiy.Op Fl M Ar core 6021be3b31SYaroslav Tykhiy.Op Fl N Ar system 6121be3b31SYaroslav Tykhiy.Op Fl P Ar ppid 6221be3b31SYaroslav Tykhiy.Op Fl U Ar uid 6321be3b31SYaroslav Tykhiy.Op Fl g Ar pgrp 6421be3b31SYaroslav Tykhiy.Op Fl j Ar jid 6521be3b31SYaroslav Tykhiy.Op Fl s Ar sid 6621be3b31SYaroslav Tykhiy.Op Fl t Ar tty 6721be3b31SYaroslav Tykhiy.Op Fl u Ar euid 6821be3b31SYaroslav Tykhiy.Ar pattern ... 6921be3b31SYaroslav Tykhiy.Sh DESCRIPTION 7021be3b31SYaroslav TykhiyThe 7121be3b31SYaroslav Tykhiy.Nm pgrep 7221be3b31SYaroslav Tykhiycommand searches the process table on the running system and prints the 7321be3b31SYaroslav Tykhiyprocess IDs of all processes that match the criteria given on the command 7421be3b31SYaroslav Tykhiyline. 7521be3b31SYaroslav Tykhiy.Pp 7621be3b31SYaroslav TykhiyThe 7721be3b31SYaroslav Tykhiy.Nm pkill 7821be3b31SYaroslav Tykhiycommand searches the process table on the running system and signals all 7921be3b31SYaroslav Tykhiyprocesses that match the criteria given on the command line. 8021be3b31SYaroslav Tykhiy.Pp 8121be3b31SYaroslav TykhiyThe following options are available: 8221be3b31SYaroslav Tykhiy.Bl -tag -width ".Fl F Ar pidfile" 8321be3b31SYaroslav Tykhiy.It Fl F Ar pidfile 8421be3b31SYaroslav TykhiyRestrict matches to a process whose PID is stored in the 8521be3b31SYaroslav Tykhiy.Ar pidfile 8621be3b31SYaroslav Tykhiyfile. 8721be3b31SYaroslav Tykhiy.It Fl G Ar gid 8821be3b31SYaroslav TykhiyRestrict matches to processes with a real group ID in the comma-separated 8921be3b31SYaroslav Tykhiylist 9021be3b31SYaroslav Tykhiy.Ar gid . 9121be3b31SYaroslav Tykhiy.It Fl I 9221be3b31SYaroslav TykhiyRequest confirmation before attempting to signal each process. 9321be3b31SYaroslav Tykhiy.It Fl L 9421be3b31SYaroslav TykhiyThe 9521be3b31SYaroslav Tykhiy.Ar pidfile 9621be3b31SYaroslav Tykhiyfile given for the 9721be3b31SYaroslav Tykhiy.Fl F 9821be3b31SYaroslav Tykhiyoption must be locked with the 9921be3b31SYaroslav Tykhiy.Xr flock 2 10021be3b31SYaroslav Tykhiysyscall or created with 10121be3b31SYaroslav Tykhiy.Xr pidfile 3 . 10221be3b31SYaroslav Tykhiy.It Fl M Ar core 10321be3b31SYaroslav TykhiyExtract values associated with the name list from the specified core 10421be3b31SYaroslav Tykhiyinstead of the currently running system. 10521be3b31SYaroslav Tykhiy.It Fl N Ar system 10621be3b31SYaroslav TykhiyExtract the name list from the specified system instead of the default, 10721be3b31SYaroslav Tykhiywhich is the kernel image the system has booted from. 10821be3b31SYaroslav Tykhiy.It Fl P Ar ppid 10921be3b31SYaroslav TykhiyRestrict matches to processes with a parent process ID in the 11021be3b31SYaroslav Tykhiycomma-separated list 11121be3b31SYaroslav Tykhiy.Ar ppid . 11221be3b31SYaroslav Tykhiy.It Fl S 11321be3b31SYaroslav TykhiySearch also in system processes (kernel threads). 11421be3b31SYaroslav Tykhiy.It Fl U Ar uid 11521be3b31SYaroslav TykhiyRestrict matches to processes with a real user ID in the comma-separated 11621be3b31SYaroslav Tykhiylist 11721be3b31SYaroslav Tykhiy.Ar uid . 11821be3b31SYaroslav Tykhiy.It Fl d Ar delim 11921be3b31SYaroslav TykhiySpecify a delimiter to be printed between each process ID. 12021be3b31SYaroslav TykhiyThe default is a newline. 12121be3b31SYaroslav TykhiyThis option can only be used with the 12221be3b31SYaroslav Tykhiy.Nm pgrep 12321be3b31SYaroslav Tykhiycommand. 1240a091aebSBrian Somers.It Fl a 1250a091aebSBrian SomersInclude process ancestors in the match list. 1260a091aebSBrian SomersBy default, the current 1270a091aebSBrian Somers.Nm pgrep 1280a091aebSBrian Somersor 1290a091aebSBrian Somers.Nm pkill 1300a091aebSBrian Somersprocess and all of its ancestors are excluded (unless 1310a091aebSBrian Somers.Fl v 1320a091aebSBrian Somersis used). 13321be3b31SYaroslav Tykhiy.It Fl f 13421be3b31SYaroslav TykhiyMatch against full argument lists. 13521be3b31SYaroslav TykhiyThe default is to match against process names. 13621be3b31SYaroslav Tykhiy.It Fl g Ar pgrp 13721be3b31SYaroslav TykhiyRestrict matches to processes with a process group ID in the comma-separated 13821be3b31SYaroslav Tykhiylist 13921be3b31SYaroslav Tykhiy.Ar pgrp . 14021be3b31SYaroslav TykhiyThe value zero is taken to mean the process group ID of the running 14121be3b31SYaroslav Tykhiy.Nm pgrep 14221be3b31SYaroslav Tykhiyor 14321be3b31SYaroslav Tykhiy.Nm pkill 14421be3b31SYaroslav Tykhiycommand. 14521be3b31SYaroslav Tykhiy.It Fl i 14621be3b31SYaroslav TykhiyIgnore case distinctions in both the process table and the supplied pattern. 14721be3b31SYaroslav Tykhiy.It Fl j Ar jid 14821be3b31SYaroslav TykhiyRestrict matches to processes inside jails with a jail ID in the comma-separated 14921be3b31SYaroslav Tykhiylist 15021be3b31SYaroslav Tykhiy.Ar jid . 15121be3b31SYaroslav TykhiyThe value 15221be3b31SYaroslav Tykhiy.Dq Li any 15321be3b31SYaroslav Tykhiymatches processes in any jail. 15421be3b31SYaroslav TykhiyThe value 15521be3b31SYaroslav Tykhiy.Dq Li none 15621be3b31SYaroslav Tykhiymatches processes not in jail. 15721be3b31SYaroslav Tykhiy.It Fl l 15821be3b31SYaroslav TykhiyLong output. 1593ba0e470SBrian SomersFor 1603ba0e470SBrian Somers.Nm pgrep , 1613ba0e470SBrian Somersprint the process name in addition to the process ID for each matching 16221be3b31SYaroslav Tykhiyprocess. 16321be3b31SYaroslav TykhiyIf used in conjunction with 16421be3b31SYaroslav Tykhiy.Fl f , 16521be3b31SYaroslav Tykhiyprint the process ID and the full argument list for each matching process. 1663ba0e470SBrian SomersFor 1673ba0e470SBrian Somers.Nm pkill , 1683ba0e470SBrian Somersdisplay the kill command used for each process killed. 16921be3b31SYaroslav Tykhiy.It Fl n 17021be3b31SYaroslav TykhiySelect only the newest (most recently started) of the matching processes. 17121be3b31SYaroslav Tykhiy.It Fl o 17221be3b31SYaroslav TykhiySelect only the oldest (least recently started) of the matching processes. 1737b0706f6SPawel Jakub Dawidek.It Fl q 1747b0706f6SPawel Jakub DawidekDo not write anything to standard output. 17521be3b31SYaroslav Tykhiy.It Fl s Ar sid 17621be3b31SYaroslav TykhiyRestrict matches to processes with a session ID in the comma-separated 17721be3b31SYaroslav Tykhiylist 17821be3b31SYaroslav Tykhiy.Ar sid . 17921be3b31SYaroslav TykhiyThe value zero is taken to mean the session ID of the running 18021be3b31SYaroslav Tykhiy.Nm pgrep 18121be3b31SYaroslav Tykhiyor 18221be3b31SYaroslav Tykhiy.Nm pkill 18321be3b31SYaroslav Tykhiycommand. 18421be3b31SYaroslav Tykhiy.It Fl t Ar tty 18521be3b31SYaroslav TykhiyRestrict matches to processes associated with a terminal in the 18621be3b31SYaroslav Tykhiycomma-separated list 18721be3b31SYaroslav Tykhiy.Ar tty . 18818aa158fSEd SchoutenTerminal names may be of the form 18918aa158fSEd Schouten.Pa tty Ns Ar xx 19018aa158fSEd Schoutenor the shortened form 19118aa158fSEd Schouten.Ar xx . 19221be3b31SYaroslav TykhiyA single dash 19321be3b31SYaroslav Tykhiy.Pq Ql - 19421be3b31SYaroslav Tykhiymatches processes not associated with a terminal. 19521be3b31SYaroslav Tykhiy.It Fl u Ar euid 19621be3b31SYaroslav TykhiyRestrict matches to processes with an effective user ID in the 19721be3b31SYaroslav Tykhiycomma-separated list 19821be3b31SYaroslav Tykhiy.Ar euid . 19921be3b31SYaroslav Tykhiy.It Fl v 20021be3b31SYaroslav TykhiyReverse the sense of the matching; display processes that do not match the 20121be3b31SYaroslav Tykhiygiven criteria. 20221be3b31SYaroslav Tykhiy.It Fl x 20321be3b31SYaroslav TykhiyRequire an exact match of the process name, or argument list if 20421be3b31SYaroslav Tykhiy.Fl f 20521be3b31SYaroslav Tykhiyis given. 20621be3b31SYaroslav TykhiyThe default is to match any substring. 20721be3b31SYaroslav Tykhiy.It Fl Ns Ar signal 20821be3b31SYaroslav TykhiyA non-negative decimal number or symbolic signal name specifying the signal 20921be3b31SYaroslav Tykhiyto be sent instead of the default 21021be3b31SYaroslav Tykhiy.Dv TERM . 21121be3b31SYaroslav TykhiyThis option is valid only when given as the first argument to 21221be3b31SYaroslav Tykhiy.Nm pkill . 21321be3b31SYaroslav Tykhiy.El 21421be3b31SYaroslav Tykhiy.Pp 21521be3b31SYaroslav TykhiyIf any 21621be3b31SYaroslav Tykhiy.Ar pattern 21721be3b31SYaroslav Tykhiyoperands are specified, they are used as regular expressions to match 21821be3b31SYaroslav Tykhiythe command name or full argument list of each process. 21921be3b31SYaroslav TykhiyIf the 22021be3b31SYaroslav Tykhiy.Fl f 22121be3b31SYaroslav Tykhiyoption is not specified, then the 22221be3b31SYaroslav Tykhiy.Ar pattern 22321be3b31SYaroslav Tykhiywill attempt to match the command name. 22421be3b31SYaroslav TykhiyHowever, presently 22521be3b31SYaroslav Tykhiy.Fx 22621be3b31SYaroslav Tykhiywill only keep track of the first 19 characters of the command 22721be3b31SYaroslav Tykhiyname for each process. 22821be3b31SYaroslav TykhiyAttempts to match any characters after the first 19 of a command name 22921be3b31SYaroslav Tykhiywill quietly fail. 23021be3b31SYaroslav Tykhiy.Pp 23121be3b31SYaroslav TykhiyNote that a running 23221be3b31SYaroslav Tykhiy.Nm pgrep 23321be3b31SYaroslav Tykhiyor 23421be3b31SYaroslav Tykhiy.Nm pkill 23521be3b31SYaroslav Tykhiyprocess will never consider itself nor system processes (kernel threads) as 23621be3b31SYaroslav Tykhiya potential match. 23721be3b31SYaroslav Tykhiy.Sh EXIT STATUS 23821be3b31SYaroslav TykhiyThe 23921be3b31SYaroslav Tykhiy.Nm pgrep 24021be3b31SYaroslav Tykhiyand 24121be3b31SYaroslav Tykhiy.Nm pkill 24221be3b31SYaroslav Tykhiyutilities 24321be3b31SYaroslav Tykhiyreturn one of the following values upon exit: 24421be3b31SYaroslav Tykhiy.Bl -tag -width indent 24521be3b31SYaroslav Tykhiy.It 0 24621be3b31SYaroslav TykhiyOne or more processes were matched. 24721be3b31SYaroslav Tykhiy.It 1 24821be3b31SYaroslav TykhiyNo processes were matched. 24921be3b31SYaroslav Tykhiy.It 2 25021be3b31SYaroslav TykhiyInvalid options were specified on the command line. 25121be3b31SYaroslav Tykhiy.It 3 25221be3b31SYaroslav TykhiyAn internal error occurred. 25321be3b31SYaroslav Tykhiy.El 25421be3b31SYaroslav Tykhiy.Sh COMPATIBILITY 25521be3b31SYaroslav TykhiyHistorically the option 25621be3b31SYaroslav Tykhiy.Dq Fl j Li 0 25721be3b31SYaroslav Tykhiymeans any jail, although in other utilities such as 25821be3b31SYaroslav Tykhiy.Xr ps 1 25921be3b31SYaroslav Tykhiyjail ID 26021be3b31SYaroslav Tykhiy.Li 0 26121be3b31SYaroslav Tykhiyhas the opposite meaning, not in jail. 26221be3b31SYaroslav TykhiyTherefore 26321be3b31SYaroslav Tykhiy.Dq Fl j Li 0 26421be3b31SYaroslav Tykhiyis deprecated, and its use is discouraged in favor of 26521be3b31SYaroslav Tykhiy.Dq Fl j Li any . 26621be3b31SYaroslav Tykhiy.Sh SEE ALSO 26721be3b31SYaroslav Tykhiy.Xr kill 1 , 26821be3b31SYaroslav Tykhiy.Xr killall 1 , 26921be3b31SYaroslav Tykhiy.Xr ps 1 , 27021be3b31SYaroslav Tykhiy.Xr flock 2 , 27121be3b31SYaroslav Tykhiy.Xr kill 2 , 27221be3b31SYaroslav Tykhiy.Xr sigaction 2 , 27321be3b31SYaroslav Tykhiy.Xr pidfile 3 , 27421be3b31SYaroslav Tykhiy.Xr re_format 7 27521be3b31SYaroslav Tykhiy.\" Xr signal 7 27621be3b31SYaroslav Tykhiy.Sh HISTORY 27721be3b31SYaroslav TykhiyThe 27821be3b31SYaroslav Tykhiy.Nm pkill 27921be3b31SYaroslav Tykhiyand 28021be3b31SYaroslav Tykhiy.Nm pgrep 28121be3b31SYaroslav Tykhiyutilities 28221be3b31SYaroslav Tykhiyfirst appeared in 28321be3b31SYaroslav Tykhiy.Nx 1.6 . 28421be3b31SYaroslav TykhiyThey are modelled after utilities of the same name that appeared in Sun 28521be3b31SYaroslav TykhiySolaris 7. 28621be3b31SYaroslav TykhiyThey made their first appearance in 28721be3b31SYaroslav Tykhiy.Fx 5.3 . 28821be3b31SYaroslav Tykhiy.Sh AUTHORS 28921be3b31SYaroslav Tykhiy.An Andrew Doran 29021be3b31SYaroslav Tykhiy.Aq ad@NetBSD.org 291