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.
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.
If our Nginx is running on port 80, then we can use the netstat -anp | grep :80 command to determine whether Nginx is started.
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!