1. 程式人生 > >Nginx日子切割腳本

Nginx日子切割腳本

rda usr pat 腳本 AC ase CA pan ID

#!/bin/bash
#nginx日誌切割腳本
[ $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

Nginx日子切割腳本