#!/bin/bash # Author: Wang Xiaoqiang # ReadMe: Nginx access log split script # crontab -e # 59 23 * * * sh /script/nginx_split.sh LOG_PATH='/usr/local/nginx/logs' LOG_NAME='access.log' BACKUP_DIR='/data/backup/baklog' dir_time_stamp=`date +%Y%m` file_time_stamp=`date +%Y%m%d` [ ! -e $BACKUP_DIR ] && mkdir $BACKUP_DIR [ ! -e $BACKUP_DIR/$dir_time_stamp ] && mkdir $BACKUP_DIR/$dir_time_stamp mv $LOG_PATH/$LOG_NAME $BACKUP_DIR/$dir_time_stamp/${file_time_stamp}_$LOG_NAME kill -USR1 `cat $LOG_PATH/nginx.pid` # END