2002-02-02 04:17:29 +05:30
|
|
|
.\" Manual page for pgrep / pkill.
|
|
|
|
.\" Licensed under version 2 of the GNU General Public License.
|
|
|
|
.\" Copyright 2000 Kjetil Torgrim Homme
|
|
|
|
.\"
|
2012-10-11 16:04:50 +05:30
|
|
|
.TH PGREP "1" "October 2012" "procps-ng" "User Commands"
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH NAME
|
|
|
|
pgrep, pkill \- look up or signal processes based on name and other attributes
|
|
|
|
.SH SYNOPSIS
|
2011-09-28 02:12:51 +05:30
|
|
|
.B pgrep
|
|
|
|
[options] pattern
|
|
|
|
.br
|
|
|
|
.B pkill
|
|
|
|
[options] pattern
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH DESCRIPTION
|
2011-09-28 02:12:51 +05:30
|
|
|
.B pgrep
|
|
|
|
looks through the currently running processes and lists the process IDs which
|
2013-02-13 23:06:11 +05:30
|
|
|
match the selection criteria to stdout. All the criteria have to match.
|
2011-09-28 02:12:51 +05:30
|
|
|
For example,
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
|
|
|
$ pgrep \-u root sshd
|
|
|
|
.PP
|
2011-09-28 02:12:51 +05:30
|
|
|
will only list the processes called
|
|
|
|
.B sshd
|
|
|
|
AND owned by
|
|
|
|
.BR root .
|
2002-02-02 04:17:29 +05:30
|
|
|
On the other hand,
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
|
|
|
$ pgrep \-u root,daemon
|
|
|
|
.PP
|
2011-09-28 02:12:51 +05:30
|
|
|
will list the processes owned by
|
|
|
|
.B root
|
|
|
|
OR
|
|
|
|
.BR daemon .
|
|
|
|
.PP
|
|
|
|
.B pkill
|
|
|
|
will send the specified signal (by default
|
|
|
|
.BR SIGTERM )
|
2002-02-02 04:17:29 +05:30
|
|
|
to each process instead of listing them on stdout.
|
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-\fR\fIsignal\fP
|
|
|
|
.TQ
|
|
|
|
\fB\-\-signal\fR \fIsignal\fR
|
|
|
|
Defines the signal to send to each matched process. Either the numeric or
|
|
|
|
the symbolic signal name can be used.
|
|
|
|
.RB ( pkill
|
|
|
|
only.)
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-c\fR, \fB\-\-count\fR
|
2012-01-25 13:47:49 +05:30
|
|
|
Suppress normal output; instead print a count of matching processes. When
|
|
|
|
count does not match anything, e.g. returns zero, the command will return
|
2013-03-11 11:30:00 +05:30
|
|
|
non-zero value.
|
2011-09-28 02:12:51 +05:30
|
|
|
.TP
|
2012-10-11 16:04:50 +05:30
|
|
|
\fB\-d\fR, \fB\-\-delimiter\fR \fIdelimiter\fP
|
2011-09-28 02:12:51 +05:30
|
|
|
Sets the string used to delimit each process ID in the output (by default a
|
|
|
|
newline).
|
|
|
|
.RB ( pgrep
|
|
|
|
only.)
|
|
|
|
.TP
|
|
|
|
\fB\-f\fR, \fB\-\-full\fR
|
|
|
|
The
|
|
|
|
.I pattern
|
|
|
|
is normally only matched against the process name. When
|
|
|
|
.B \-f
|
|
|
|
is set, the full command line is used.
|
|
|
|
.TP
|
|
|
|
\fB\-g\fR, \fB\-\-pgroup\fR \fIpgrp\fP,...
|
|
|
|
Only match processes in the process group IDs listed. Process group 0 is
|
|
|
|
translated into
|
|
|
|
.BR pgrep 's
|
|
|
|
or
|
|
|
|
.BR pkill 's
|
|
|
|
own process group.
|
|
|
|
.TP
|
|
|
|
\fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
|
|
|
|
Only match processes whose real group ID is listed. Either the numerical or
|
|
|
|
symbolical value may be used.
|
|
|
|
.TP
|
2012-05-06 16:34:41 +05:30
|
|
|
\fB\-l\fR, \fB\-\-list\-name\fR
|
2011-09-28 02:12:51 +05:30
|
|
|
List the process name as well as the process ID.
|
|
|
|
.RB ( pgrep
|
|
|
|
only.)
|
2012-05-06 16:34:41 +05:30
|
|
|
.TP
|
2012-08-18 05:50:27 +05:30
|
|
|
\fB\-a\fR, \fB\-\-list\-full\fR
|
|
|
|
List the full command line as well as the process ID.
|
|
|
|
.RB ( pgrep
|
|
|
|
only.)
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-n\fR, \fB\-\-newest\fR
|
|
|
|
Select only the newest (most recently started) of the matching processes.
|
|
|
|
.TP
|
|
|
|
\fB\-o\fR, \fB\-\-oldest\fR
|
|
|
|
Select only the oldest (least recently started) of the matching processes.
|
|
|
|
.TP
|
|
|
|
\fB\-P\fR, \fB\-\-parent\fR \fIppid\fP,...
|
2002-02-02 04:17:29 +05:30
|
|
|
Only match processes whose parent process ID is listed.
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-s\fR, \fB\-\-session\fR \fIsid\fP,...
|
2002-02-02 04:17:29 +05:30
|
|
|
Only match processes whose process session ID is listed. Session ID 0
|
2011-09-28 02:12:51 +05:30
|
|
|
is translated into
|
|
|
|
.BR pgrep 's
|
|
|
|
or
|
|
|
|
.BR pkill 's
|
|
|
|
own session ID.
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
|
|
|
|
Only match processes whose controlling terminal is listed. The terminal name
|
|
|
|
should be specified without the "/dev/" prefix.
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-u\fR, \fB\-\-euid\fR \fIeuid\fP,...
|
|
|
|
Only match processes whose effective user ID is listed. Either the numerical
|
|
|
|
or symbolical value may be used.
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-U\fR, \fB\-\-uid\fR \fIuid\fP,...
|
|
|
|
Only match processes whose real user ID is listed. Either the numerical or
|
|
|
|
symbolical value may be used.
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-v\fR, \fB\-\-inverse\fR\fR
|
2013-03-11 11:30:00 +05:30
|
|
|
Negates the matching. This option is usually used in
|
|
|
|
.BR pgrep 's
|
2013-02-13 23:06:11 +05:30
|
|
|
context. In
|
|
|
|
.BR pkill 's
|
2012-02-14 01:48:54 +05:30
|
|
|
context the short option is disabled to avoid accidental usage of the option.
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2013-03-18 16:28:47 +05:30
|
|
|
\fB\-w\fR, \fB\-\-lightweight\fR\fR
|
|
|
|
Shows all thread ids instead of pids in
|
|
|
|
.BR pgrep 's
|
|
|
|
context. In
|
|
|
|
.BR pkill 's
|
|
|
|
context this option is disabled.
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
\fB\-x\fR, \fB\-\-exact\fR\fR
|
2013-02-13 23:06:11 +05:30
|
|
|
Only match processes whose names (or command line if \-f is specified)
|
2011-09-28 02:12:51 +05:30
|
|
|
.B exactly
|
|
|
|
match the
|
|
|
|
.IR pattern .
|
|
|
|
.TP
|
|
|
|
\fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
|
|
|
|
Read
|
|
|
|
.IR PID 's
|
|
|
|
from file. This option is perhaps more useful for
|
|
|
|
.B pkill
|
|
|
|
than
|
|
|
|
.BR pgrep .
|
|
|
|
.TP
|
|
|
|
\fB\-L\fR, \fB\-\-logpidfile\fR
|
|
|
|
Fail if pidfile (see -F) not locked.
|
|
|
|
.TP
|
|
|
|
\fB\-V\fR, \fB\-\-version\fR
|
|
|
|
Display version information and exit.
|
|
|
|
.TP
|
|
|
|
\fB\-h\fR, \fB\-\-help\fR
|
|
|
|
Display help and exit.
|
|
|
|
.PD
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH OPERANDS
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
.I pattern
|
|
|
|
Specifies an Extended Regular Expression for matching against the process
|
|
|
|
names or command lines.
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH EXAMPLES
|
2011-09-28 02:12:51 +05:30
|
|
|
Example 1: Find the process ID of the
|
|
|
|
.B named
|
|
|
|
daemon:
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
|
|
|
$ pgrep \-u root named
|
|
|
|
.PP
|
2011-09-28 02:12:51 +05:30
|
|
|
Example 2: Make
|
|
|
|
.B syslog
|
|
|
|
reread its configuration file:
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
|
|
|
$ pkill \-HUP syslogd
|
|
|
|
.PP
|
2011-09-28 02:12:51 +05:30
|
|
|
Example 3: Give detailed information on all
|
|
|
|
.B xterm
|
|
|
|
processes:
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
|
|
|
$ ps \-fp $(pgrep \-d, \-x xterm)
|
|
|
|
.PP
|
2011-09-28 02:12:51 +05:30
|
|
|
Example 4: Make all
|
|
|
|
.B netscape
|
|
|
|
processes run nicer:
|
2011-02-23 13:47:54 +05:30
|
|
|
.IP
|
2011-09-28 02:12:51 +05:30
|
|
|
$ renice +4 $(pgrep netscape)
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH "EXIT STATUS"
|
2011-02-23 13:47:54 +05:30
|
|
|
.PD 0
|
2002-02-02 04:17:29 +05:30
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
0
|
2002-02-02 04:17:29 +05:30
|
|
|
One or more processes matched the criteria.
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
1
|
2002-02-02 04:17:29 +05:30
|
|
|
No processes matched.
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
2
|
2002-02-02 04:17:29 +05:30
|
|
|
Syntax error in the command line.
|
|
|
|
.TP
|
2011-09-28 02:12:51 +05:30
|
|
|
3
|
2002-02-02 04:17:29 +05:30
|
|
|
Fatal error: out of memory etc.
|
2011-09-28 02:12:51 +05:30
|
|
|
.PD
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH NOTES
|
2011-09-28 02:12:51 +05:30
|
|
|
The process name used for matching is limited to the 15 characters present in
|
|
|
|
the output of /proc/\fIpid\fP/stat. Use the \-f option to match against the
|
|
|
|
complete command line, /proc/\fIpid\fP/cmdline.
|
|
|
|
.PP
|
|
|
|
The running
|
|
|
|
.B pgrep
|
|
|
|
or
|
|
|
|
.B pkill
|
|
|
|
process will never report itself as a
|
|
|
|
match.
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH BUGS
|
2011-09-28 02:12:51 +05:30
|
|
|
The options
|
|
|
|
.B \-n
|
|
|
|
and
|
|
|
|
.B \-o
|
|
|
|
and
|
|
|
|
.B \-v
|
|
|
|
can not be combined. Let
|
|
|
|
me know if you need to do this.
|
|
|
|
.PP
|
2002-02-02 04:17:29 +05:30
|
|
|
Defunct processes are reported.
|
|
|
|
|
|
|
|
.SH "SEE ALSO"
|
2011-02-23 13:47:54 +05:30
|
|
|
.BR ps (1),
|
|
|
|
.BR regex (7),
|
|
|
|
.BR signal (7),
|
|
|
|
.BR killall (1),
|
|
|
|
.BR skill (1),
|
|
|
|
.BR kill (1),
|
|
|
|
.BR kill (2)
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH STANDARDS
|
2011-09-28 02:12:51 +05:30
|
|
|
.B pkill
|
|
|
|
and
|
|
|
|
.B pgrep
|
|
|
|
were introduced in Sun's Solaris 7. This implementation is fully compatible.
|
2002-02-02 04:17:29 +05:30
|
|
|
.SH AUTHOR
|
2012-04-16 16:25:53 +05:30
|
|
|
.UR kjetilho@ifi.uio.no
|
2011-09-28 02:12:51 +05:30
|
|
|
Kjetil Torgrim Homme
|
|
|
|
.UE
|
|
|
|
.SH "REPORTING BUGS"
|
|
|
|
Please send bug reports to
|
2012-04-16 16:25:53 +05:30
|
|
|
.UR procps@freelists.org
|
2011-09-28 02:12:51 +05:30
|
|
|
.UE
|