Nginx log cutting script

WBOY
Release: 2016-07-29 08:57:14
Original
807 people have browsed it

<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>
Copy after login

Place it in sbin of the Nginx installation directory and name it 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>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the Nginx log cutting script, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template