Nginx日志切割脚本

#!/bin/bash
#nginx日志切割脚本 脚本需要在每天的0点0分执行
[ $UID !=0 ] && {
    echo "Please run as root"
    exit 1
}

logs_path="/usr/local/nginx/logs/"
 
mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log  ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid

 

posted @ 2018-05-23 13:19  谭普利特  阅读(118)  评论(0编辑  收藏  举报