The method of checking whether nginx is started by linux
Editor to share with you the method of linux to check whether nginx is started. I hope you will learn a lot after reading this article. Let's discuss it together.
Nginx is a high-performance reverse proxy server, which is now generally used as the first-tier proxy of our website or other Web services. The first thing users request in the browser is the Nginx service. If the Nginx service does not start or ends abnormally, it will affect the normal use of the Web service. So how do I see if nginx is started? The following article will show you how to check whether Nginx is started in Linux. I hope it will be helpful to you.
Method 1: judge by process
Linux each application runs to generate a process, so we can determine whether the Nginx process is started by looking at whether it exists.
The list of processes is listed with ps-ef and filtered through grep.
For example, you can see whether the Nginx process exists by using the following command.
Ps-ef | grep nginx
Or use the following command to view the process id directly.
Ps-C nginx-o pid
This way of directly returning pid is more suitable to be used in conjunction with other programs, such as executing this command in a shell/python script to get pid, and then judging whether Nginx is started according to pid.
Method 2: judge by port
You can determine whether a Nginx is started by looking at whether a Nginx process is running on a port.
If Nginx is running on port 80, you can determine whether Nginx is started or not by the following command.
Netstat-anp | grep: 80
Lsof-iRO 80
After reading this article, I believe you have a certain understanding of linux's method of checking whether nginx is started. Want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!