Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix pgrep and pkill command

Quick links

About pgrep or pkill
Syntax
Examples
Related commands
Linux / Unix main page

About pgrep and pkill

The pgrep utility examines the active processes on the system and reports the process IDs of the processes whose attributes match the criteria specified on the command line.

Syntax

pgrep [-f] [-l] [-n] [-v] [-x] [ -d delim ] [ -P ppidlist ] [-g pgrplist ] [ -s sidlist ] [ -u euidlist ] [ -U uidlist] [-G gidlist ] [ -t termlist ] [ pattern ]

pkill [ -signal ] [-f] [-n] [-v] [-x] [ -P ppidlist ] [-g pgrplist ] [ -s sidlist ] [ -u euidlist ] [ -U uidlist] [ -G gidlist ] [ -t termlist ] [ pattern ]

-f The regular expression pattern should be matched against the full process argument string (obtained from the pr_psargs field of the /proc/nnnnn/psinfo file). If no -f option is specified, the expression is matched only against the name of the executable file (obtained from the pr_fname field of the /proc/nnnnn/psinfo file).
-l Long output format. Print the process name along with the process ID of each matching process. The process name is obtained from the pr_psargs or pr_fname field, depending on whether the -f option was specified (see above). The -l option is only valid when specified as an option to pgrep.
-n Matches only the newest (most recently created) process which meets all other specified matching criteria.
-v Reverses the sense of the matching. Matches all processes except those which meet the specified matching criteria.
-x Considers only processes whose argument string or executable file name exactly matches the specified pattern to be matching processes. The pattern match is considered to be exact when all characters in the process argument string or executable file name match the pattern.
-d delim Specifies the output delimiter string to be printed between each matching process ID. If no -d option is specified, the default is a newline character. The -d option is only valid when specified as an option to pgrep.
-P ppidlist Matches only processes whose parent process ID is in the given list.
-g pgrplist Matches only processes whose process group ID is in the given list. If group 0 is included in the list, this is interpreted as the process group ID of the pgrep or pkill process.
-s sidlist Matches only processes whose process session ID is in in the given list. If ID 0 is included in the list, this is interpreted as the session ID of the pgrep or pkill process.
-u euidlist Matches only processes whose effective user ID is in the given list. Each user ID may be specified as either a login name or a numerical user ID.
-U uidlist Matches only processes whose real user ID is in the given list. Each user ID may be specified as either a login name or a numerical user ID.
-G gidlist Matches only processes whose real group ID is in the given list. Each group ID may be specified as either a group name or a numerical group ID.
-t termlist Matches only processes which are associated with a
terminal in the given list. Each terminal is
specified as the suffix following "/dev/" of the
terminal's device path name in /dev. For example,
term/a or pts/0.
pattern Specifies an Extended Regular Expression (ERE) pattern to match against either the executable file name or full process argument string.

Related commands

kill
ps

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope