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