nginx日志切割

nginx日志切割

#!/bin/bash
#########################################################################
# File Name: ng_log.sh
# Created on: 2019-11-08 16:30:46
# Author: xieys
# Last Modified: 2019-11-08 16:30:46
# Description:
# nginx日志分割
#########################################################################

LANG=en_US.UTF-8
BASEDIR="/usr/local/nginx/logs/access/access_"
BASEFILE="/usr/local/nginx/logs/access/access.log"
log_file=${BASEDIR}`date -d "-1 day" +"%Y_%m_%d"`".log"

month=`date -d "-1 day" +"%b"`
day=`date -d "-1 day" +"%d"`
year=`date -d "-1 day" +"%Y"`

mv $BASEFILE $log_file
/usr/bin/kill -USR1 `ps -ef | grep -v " grep"|grep nginx | awk '/master/ {print $2}'`
LANG=zh_CN.UTF-8

 

posted @ 2019-11-15 10:49  Mr-谢  阅读(67)  评论(0)    收藏  举报