Home >Operation and Maintenance >Nginx >Check whether nginx is started
Check whether nginx is started?
Below I will share the process record of checking whether Nginx is started in Linux.
Recommended: "Nginx Tutorial"
Judge by process
The first method: View the process list and filter
Every Linux application will generate a process, so we can determine whether it is started by checking whether the Nginx process 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 executing this command in a 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.
Judge by port
The third method: use the netstat command
If our Nginx is running on port 80, then we can pass netstat - anp | grep :80 command to determine whether Nginx is started.
Fourth method: Use the lsof command
lsof -i:80 You can also check whether there is a process running on port 80.
The above is the detailed content of Check whether nginx is started. For more information, please follow other related articles on the PHP Chinese website!