Home  >  Article  >  Operation and Maintenance  >  How to check whether nginx is started in Linux system

How to check whether nginx is started in Linux system

PHPz
PHPzforward
2023-05-17 21:49:108442browse

First method: View the process list and filter

Every Linux application will generate a process, then we can judge whether the Nginx process is started by checking whether it exists.

Use ps -ef to list the process, and then filter it through grep.

For example: ps -ef | grep nginx You can see whether the Nginx process exists.

Second method: Check the process id directly

ps -C nginx -o pid

This method of directly returning the pid is more suitable for use in conjunction with other programs, such as Execute this command in the shell/python script to get the pid, and then use the pid to determine whether Nginx is started.

It is recommended to use this method.

Third method: Use the netstat command

If our Nginx is running on port 80, then we can use the netstat -anp | grep :80 command to determine whether Nginx is started.

What versions of Linux are there?

Linux versions include: Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and other versions. Among them, Deepin is one of the best-developed Linux distributions in China; Ubuntu Kylin is a derivative distribution based on Ubuntu; Manjaro is a Linux distribution based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP and is simple and easy to use; Ubuntu is a desktop application Mainly Linux operating system.

The above is the detailed content of How to check whether nginx is started in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete