<code><span>#!/bin/bash</span><span>## 零点执行该脚本</span><span>## Nginx 日志文件所在的目录</span> LOGS_PATH=/usr/local/nginx/logs <span>## 获取昨天的 yyyy-MM-dd</span> YESTERDAY=$(date <span>-d</span><span>"yesterday"</span> +%Y-%m-%d) <span>## 移动文件</span> mv <span>${LOGS_PATH}</span>/access_log <span>${LOGS_PATH}</span>/access_log.<span>${YESTERDAY}</span> mv <span>${LOGS_PATH}</span>/error.log <span>${LOGS_PATH}</span>/error.log.<span>${YESTERDAY}</span><span>## 向 Nginx 主进程发送 USR1 信号。USR1 信号是重新打开日志文件</span> kill -USR1 $(cat /usr/local/nginx/sbin/nginx.pid)</code>
放在Nginx 安裝目錄的 sbin 中,取名為 cut-log.sh
<code><span>#crantab</span><span>0</span><span>0</span> * * * /bin/bash /usr/<span>local</span>/nginx/sbin/cut-<span>log</span>.sh</code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了Nginx日誌切割腳本,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。