400-028-6601
建站资讯

网站建设资讯

为你提供网站建设行业资讯、网站优化知识、主机域名邮箱、网站开发常见问题等。

nginx日志切割脚本

#!/bin/bash
Logs_path='/var/log/nginx' #定义日志路径
yesterday=`date -d "yesterday" +%F`          #获取昨天的日期
cd ${Logs_path}
#切割日志
if [ -f access.log ];then
        cp {,"${yesterday}"_}access.log
        :  > access.log    #清空源access.log内容的骚操作
fi
if [ -f error.log ];then
        cp {,"${yesterday}"_}error.log
        : > error.log        #清空源error.log内容的骚操作
fi
find . -type f -name "*.log" -mtime +7 -delete        #删除7天前的所有日志

当前题目:nginx日志切割脚本
文章源于:http://www.hnjierui.cn/article/ppgedj.html

其他资讯