Nginx切割log脚本

 #!/bin/bash

# This shell executed at 00:00 everyday.
 
logs_root=("/var/log/nginx/" )
year=`date '+%Y'`
month=`date '+%m'`
day=`date '+%d'`
fileprefix=`date '+%s'`
 
for logs_path in "${logs_root[@]}";
do
    logpath=${logs_path}${year}/${month}/${day}
    if [ ! -d ${logpath} ]; then
        mkdir -p ${logpath}
    fi
 
    for logfile in `ls ${logs_path}`
    do
        if [ -f ${logs_path}${logfile} ]; then
           mv ${logs_path}${logfile} ${logpath}/${logfile}
        fi
    done
    kill -USR1 `cat /usr/local/webserver/nginx/logs/nginx.pid`
done
~      

你可能感兴趣的:(nginx,log,职场,休闲,nginx切割日志)