#!/bin/bash

LOGS_PATH=/data1/nginx/logs


#access.log 按小时备份
hour_time=`date -d today +"%Y-%m-%d_%H"`

function log_treatment (){
mkdir -p $LOGS_PATH/logback/$log_name
cd  $LOGS_PATH
mv  ${LOGS_PATH}/$log_name.log ${LOGS_PATH}/logback/$log_name/$log_name_${hour_time}.log
cd  $LOGS_PATH/logback/$log_name
zip $log_name_${hour_time}.log.zip $log_name_${hour_time}.log
rm -f ${LOGS_PATH}/logback/$log_name/$log_name_${hour_time}.log
}


log_name=www.vmyun.top.access.log
#调用函数
log_treatment

## 向 Nginx 主进程发送 USR1 信号。USR1 信号是重新打开日志文件
kill -USR1 $(cat /data1/nginx/pid/nginx.pid)