Send reopen signal to Nginx to reopen log file

Source: Internet
Author: User

Move log files First

mv/usr/local/openresty/nginx/logs/access.log/usr/local/openresty/nginx/logs/access.log.20161024

Send signal to reopen log file

KILL-USR1 $ (cat/usr/local/openresty/nginx/logs/nginx.pid)

Simply explain:

1, before the execution of KILL-USR1 ' cat ${pid_path} ', even if the file has been the MV command has only changed the name of the file, Nginx will still write to the newly named file "access.log.20161024" as usual in the log data. The reason for this is that the kernel is looking for files based on the file descriptor in the Linux system.

2, USR1 is a custom signal, that is, the process writer himself determined to receive this signal what to do. And in Nginx, it wrote its own code when it received the USR1 signal, let Nginx reopen the log file (the log reopened is the location and name set in the configuration file)

Send reopen signal to Nginx to reopen log file

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.