Home>Article>Operation and Maintenance> How to check if a process exists in linux

How to check if a process exists in linux

Karen Carpenter
Karen Carpenter Original
2022-01-04 09:30:58 13372browse

In Linux, you can use the ps command to check whether the process exists. This command is used to display the status of the current process. The syntax is "ps -ef | grep process keyword"; when the parameter is set to "ef" , you can find the format of the specified process and display the process information.

How to check if a process exists in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to check whether a process exists in Linux

If you want to check whether a process exists in Linux, you can use the ps command.

Linux ps (English spelling: process status) command is used to display the status of the current process, similar to the Windows Task Manager.

Syntax

ps [options] [--help]

Parameters:

ps has many parameters. Here we only list a few commonly used parameters and briefly introduce their meanings

  • -A List all processes

  • -w Display widening can display more information

  • -au Display wider Detailed information

  • -aux Display all itineraries containing other users

au(x) Output format:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

USER: Trip owner

  • PID: pid

  • ##%CPU: Occupied CPU usage

  • %MEM: Occupied memory usage

  • VSZ: Occupied virtual memory size

  • RSS: Occupied memory Size

  • TTY: Minor device number of tty

#STAT: Status of the trip:

  • D: Uninterruptible sleep state (usually IO process)

  • R: Executing

  • S: Static state

  • T: Suspended execution

  • Z: Does not exist but cannot be eliminated temporarily

  • W: Not enough memory pages to allocate

  • <: high priority process>
  • N: Low priority The itinerary

  • L: There are memory pages allocated and locked in the memory (real-time system or A I/O)

  • START: The itinerary Start time

  • TIME: Execution time

  • COMMAND: Executed command

Instance

Find the specified process format:

ps -ef | grep 进程关键字

For example, display the php process:

How to check if a process exists in linux

Related recommendations: "

Linux Video Tutorial

The above is the detailed content of How to check if a process exists in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn