Linux pkill and pgrep commands

Source: Internet
Author: User
For details about Linux pkill and pgrep commands, refer to pgrep, pkill & amp; ndash; to find or send signals to the process by name and other attributes. Syntax pgrep [-flvx] [-n |-o] [-ddelim] [-Pppidlist] [-gpgrplist] [-ssidlist] [-ueui... the pkill and pgrep commands in Linux are detailed with the name pgrep, pkill-find or send a signal to the process by name and other attributes. Syntax pgrep [-flvx] [-n |-o] [-d delim] [-P ppidlist] [-g pgrplist] [-s sidlist] [-u euidlist] [- U uidlist] [-G gidlist] [-J projidlist] [-t termlist] [-T taskidlist] [-c ctidlist] [-z zoneidlist] [pattern] pkill [-signal] [-fvx] [-n |-o] [-P ppidlist] [-g pgrplist] [-s sidlist] [-u euidlist] [-U uidlist] [-G gidlist] [-J projidlist] [-t termlist] [-T taskidlist] [-c ctidlist] [-z zoneidlist] [patt Ern] indicates that the pgrep program checks active processes in the system and reports the ID of the process whose properties match the specified conditions on the command line. Each process ID is represented by a single decimal number, separated by a split string and the next ID. the default split string is a new line. For each attribute option, you can specify a set of possible values separated by commas on the command line. For example, pgrep-G other and daemon match the process where the real group ID is other or daemon. If multiple conditions are assigned, these matching conditions are calculated according to the logical AND "AND" rules. For example, the attributes of pgrep-G other, daemon-U root, and daemon matching processes are: (the real group ID is other or daemon) and (the real user ID is root or daemon) the pkill function is the same as the pgrep function, except that the matched process is notified by a signal, it is like replacing the output of the pgrep process ID with kill (1. A signal name or number can be used as the first command line option for pkill. The following options are supported:-c ctidlist only matches The process of IDs listed in The list. -D delim specifies the string to be split between each matched process ID. If the-d option is not specified, the new line character is used by default. The-d option is only valid in the pgrep command. -F regular expression mode matches the execution with the complete process parameter string (obtained from the pr_psargs field of the/proc/nnnnn/psinfo file. If the-f option is not available, the expression only matches the execution file name (obtained from the pr_fname field of the/proc/nnnnn/psinfo file. -G pgrplist only matches the process of the process Group ID in the given list. If group 0 is included in the list, it is interpreted as the group ID of the pgrep or pkill process. -G gidlist only matches the process of the real group ID in the given list. Each group ID can be specified by the group name or number Group ID. -J projidlist matches the process of the Project ID in the given list. Each project ID can be specified by the project name or digital project ID. -L long format output. Output the name of each matching process along with the process ID. The process name is obtained from the pr_psargs or pr_fname field, depending on whether the-f option is specified. The-l option is only valid in the pgrep command. -N matches the latest (recently generated) processes that meet all other matching conditions. It cannot be used with the-o option. -O matches the oldest (earliest generated) processes that meet all other matching conditions. It cannot be used with the-n option. -P ppidlist only matches the process with the parent process ID in the given list. -S sidlist only matches the process in the specified list of process session IDs. If ID 0 is in the list, this is interpreted as the session ID of the pgrep or pikill process. -T termlist only matches the process associated with the terminal in the given list. Each terminal is specified as the suffix of the terminal device path name in/dev. For example, term/a or pts/0. -T taskidlist only matches the process of the task ID in the given list. If ID 0 is included in the list, this is interpreted as the session ID of the pgrep or pikill process. -U euidlist only matches the processes in the specified list of valid user IDs. Each user ID can be specified by a login name or a digital user ID. -U uidlist only matches the process of the real user ID in the given list. Each user ID can be specified by a login name or a digital user ID. -V reverse matching. All matching processes except matching conditions. -X only considers that the parameter string or execution file name of a process matches the specified pattern correctly. Mode is considered accurate when all characters in the process parameter string or executable file name match mode. -Z zoneidlist only matches the process of the region ID in the given list. Each region ID can be specified by a region name or a region ID of a number. This option is only valid in the global region. If the pkill program sends signals to processes in other regions, the {PRIV_PROC_ZONE} privilege must be declared in the city. -Signal indicates the signal sent to each matching process. If not specified, SIGTERM is the default signal. -Signal is only valid as the first option in the pkill command. A signal can be a symbolic name defined in signal. h without a SIG prefix, but also a corresponding signal value. The following operations are supported: pattern specifies an Extended Regular Expression (ERE) mode to match the executable file name or complete process parameter string. For a complete description of the ERE syntax, see regex (5 ). Example 1 obtain a process ID and obtain the sendmail process ID: example % pgrep-x-u root sendmail283 example 2 terminate a process to terminate the recently generated xterm: example % pkill-n xterm Exit Status the following Exit value is returned: 0 one or more processes are matched. 1. no process is matched. 2. Invalid command line parameters are specified. 3. a fatal error occurs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.