Linux end nginx with PID File

Source: Internet
Author: User
ArticleDirectory
    • What is a PID file?
    • Nginx default PID File
    • Modify the PID in the configuration file
    • Stop nginx with PID File
    • Reload the configuration file with the PID File

The following command is generally used to restart nginx:

 
Kill-Quit 26000

In this example, 26000 is the main process Number of nginx.

 

Every time, you need to run the ps command to query the main process Number of nginx, which is very troublesome. In the book "Practical nginx: replacing Apache with a high-performance WEB server", we mentioned the method of using the PID file. Unfortunately, something is missing from the command. Here we provide the complete command.

 

What is a PID file?

 

The PID file is a plain text file that records the PID of the process.

The following is the content of a PID file ::

 
26032

 

Nginx default PID File

Nginx uses the PID file to record the PID of the master process. If it is not specified during compilation, its path is:

 
<Prefix>/logs/nginx. PID

<Prefix> is the installation path of nginx.

 

If you want to modify the default PID file path, you can add the configuration during compilation. The parameters are as follows ::

 
./Configure -- PID-Path =/data/test/ngx. PID

After it is specified, the default PID file path is changed ::

 
/Data/test/ngx. PID

If only the path is specified and no PID file name is specified, the PID file name is still nginx. PID.

 

Modify the PID in the configuration file

In addition to the default value and the modification during compilation, you can also modify it in the nginx configuration file. As follows:

 
Pid/data/test/nginx. PID;

 

The modified value is only valid for nginx that uses the configuration file.

 

Stop nginx with PID File

Assume that the PID file path is/data/logs/nginx. PID.

 
Kill-Quit 'cat/data/logs/nginx. Pi'

 

Reload the configuration file with the PID File
 
Kill-HUP 'cat/data/logs/nginx. Pi'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.