按天切割日志,每天生成一个日志文件

#!/bin/sh
# Program:
# Auto cut nginx log script.

# nginx日志路径
LOGS_PATH=/usr/local/nginx-1.9.3/logs
TODAY=$(date -d 'today' +%Y-%m-%d)

# 移动日志并改名
mv ${LOGS_PATH}/error.log ${LOGS_PATH}/error_${TODAY}.log
mv ${LOGS_PATH}/access.log ${LOGS_PATH}/access_${TODAY}.log

# 向nginx主进程发送重新打开日志文件的信号
kill -USR1 $(cat /usr/local/nginx-1.9.3/logs/nginx.pid)