SYNOPSIS
pgrep [-flnovx] [-d delim] [-P ppidlist] [-g pgrplist] [-s sidlist]
[-u euidlist] [-U uidlist] [-G gidlist] [-t termlist] [pattern]
pkill [-signal] [-fnovx] [-P ppidlist] [-g pgrplist] [-s sidlist]
[-u euidlist] [-U uidlist] [-G gidlist] [-t termlist] [pattern]
DESCRIPTION
Pgrep searches the currently active processes for occurences of the
specified pattern and prints the process IDs of the matching ones.
Pattern is treated as an extended regular expression as described in
egrep(1). A number of options can be used in addition to the pattern
(or without specifying pattern) to further restrict the set of matching
processes. Multiple criteria can be specified for each of these
options, separated by commas or blanks, or by giving the option more
than once. In this case, all processes that match any of the given
criteria are considered matches. If more than one kind of criterion is
specified, a process must match each kind of criterion.
Pkill is similar to pgrep, but a signal (SIGTERM by default) is sent to
matching processes instead of printing its process ID. The signal can
be changed with the -signal argument; this argument must appear before
all options to be recognized. Signal can be either numeric or symbolic
with the SIG prefix omitted (as in QUIT for SIGQUIT).
Zombie processes and the current pgrep or pkill process are never
included.
Both commands accept the following options:
-d delim Use the specified delimiter string to separate process IDs
in output. By default, a newline character is used. This
option is accepted by pgrep only.
-f Use the command line arguments of each process instead of
the name of its executable file for matching, and, if -l is
also specified, for printing.
-g pgrplist Restrict matches to processes whose process group ID
appears in pgrplist. If an ID is `0', the process group ID
of the current process is used.
-G gidlist Restrict matches to processes whose real group ID appears
in gidlist.
-l Print the command name in addition to the process ID. This
option is accepted by pgrep only.
-n Select only the newest (most recently created) process of
all processes that matched the other criteria. Cannot be
combined with -o.
-u uidlist Restrict matches to processes whose effective user ID
appears in uidlist.
-U uidlist Restrict matches to processes whose real user ID appears in
uidlist.
-v Reverse the match, that is, select all processes that fail
to fulfill the given criteria.
-x Require the entire process name to be matched, as if pat-
tern was surrounded by `^( )$'.
EXAMPLES
Determine the process ID of the inetd process:
pgrep -x inetd
Print all processes that have a first argument starting with /bin/
along with their arguments:
pgrep -l -f '^/bin/'
Send a SIGHUP signal to all processes that are owned by either the root
or the daemon user and are children of the init process (process ID 1):
pkill -HUP -u root,daemon -P 1
ENVIRONMENT VARIABLES
LANG, LC_ALL
See locale(7).
LC_COLLATE
Affects the collation order for range expressions, equivalence
classes, and collation symbols in extended regular expressions.
LC_CTYPE
Determines the mapping of bytes to characters and the availabil-
ity and composition of character classes in extended regular
expressions.
SEE ALSO
egrep(1), ps(1), locale(7)
DIAGNOSTICS
Pgrep and Pkill exit with
0 if matching processes were found, and the -v option was not
specified;
1 if no matching processes were found, or the -v option was speci-
fied without any matches;
Man(1) output converted with
man2html