Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the pgrep command of linux to retrieve the currently running process

Shulou Source: shulou.com Published: 2022-06-02 18:40:41 09月28日 Update

This article mainly introduces the use of linux's pgrep command to retrieve the currently running process, the article is very detailed, has a certain reference value, interested friends must read it!

The pgrep command is to retrieve the running process, showing that the matching criterion is the process's PID, which can be matched with a regular expression to match the process or the command line.

When selecting a process owner, the default matching rule is the logical and relationship.

Syntax format: pgrep [parameters] [mode]

Common parameters:

-d sets a string, each process ID-f mode parameter used to separate the output is only used to match the process name-I list the process name and process ID-P only select the process that matches the specified parent process ID-u selection matches only the specified valid user ID process-U selection matches only the process that specifies the real user ID

Reference example

Query the PID of the bash process started by user root:

[root@linuxcool ~] # pgrep-u root bash above is used to retrieve all the contents of the currently running process using the pgrep command of linux. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Process command selection being retrieving running parameter user content pattern reference valid value interest criterion character string instance boy partner Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Apple vpn Linux