新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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.wjwzjz.com/article/ppgedj.html
在线咨询
服务热线
服务热线:028-86922220
TOP