Requirement Reason: Nginx does not have the log cutting function, the log volume is large, convenient analysis. Implementation purpose: Complete Nginx log cutting, and according to the time named Brief command: Mv/usr/local/tengine/logs/access.log/usr/local/tengine/logs/access-date.logkill- USER1 Nginx main process number. Explanation: Through the MV command to rename the log, and through the Kill-user1 nginx-id command, tell Nginx to write a new log, or Nginx will not continue to write the log after the MV. We can get the main process number of Nginx by Nginx.pid file. Kill-user1 ' Cat/usr/local/tengine/logs/nginx.pid ' detailed script is as follows: ####################################################### #################!/bin/bashlogs_bak_path= "/usr/local/tengine/logs/wanbu_nginx_log" logs_path= "/usr/local/ Tengine/logs "time=" date "+%y-%m-%d" ' mv $logs _path/wanbu.access.log $logs _bak_path/wanbu.access. $TIME. Logkill- USER1 ' Cat/usr/local/tengine/logs/nginx.pid '
Linux Shell:nginx log Cutting scripts