Nginx配置文件nginx.conf 參考:http://www.2cto.com/os/201212/176520.htmlhtml
Nginx自動切分日誌:nginx
nignx沒有自動分開文件存儲日誌的機制。shell
shell腳本文件nginx_log_division.sh內容以下:bash
logs_path="/data/wwwlogs/"spa
log_name="xxx.log"日誌
pid_path="/usr/local/nginx/logs/nginx.pid"code
mv \({logs_path}\){log_name} \({logs_path}\){log_name}_$(date --date="LAST WEEK" +"%Y-%m-d").loghtm
kill -USR1 cat ${pid_path}
get
上面shell腳本的原理是:先把之前的日誌文件移動重命名成一個,目的是就是備份。io