Linux / UNIX: Find out or determine if process PID is running

Linux / UNIX: Find out or determine if process PID is running

To determine if a process with a specific process ID (PID) is running on a Linux or UNIX system, you can use the ps command with the -p option.

ps -p PID
Source:ww‮l.w‬autturi.com

Replace PID with the PID of the process that you want to check.

For example, to check if the process with PID 1234 is running:

ps -p 1234

If the process is running, the ps command will display information about the process. If the process is not running, the ps command will not display any output.

You can also use the pgrep command to check if a process is running. The pgrep command searches for processes based on their names, and returns the PIDs of the matching processes.

pgrep PROCESS_NAME

Replace PROCESS_NAME with the name of the process that you want to check.

For example, to check if the httpd process is running:

pgrep httpd

If the process is running, the pgrep command will display the PIDs of the matching processes. If the process is not running, the pgrep command will not display any output.

Created Time:2017-10-29 22:08:56  Author:lautturi