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://xwwzsj.com/article/ppgedj.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款