首页 > 代码库 > 定时切割nginx日志

定时切割nginx日志

#!/bin/bash#desc: cut nginx log#this script run at 00:00LOG_PATH=‘/usr/local/nginx/logs/‘;LOG_BACK_PATH=‘/home/www/log/‘$(date -d ‘-1 days‘ +‘%Y/%m/‘);mkdir -p $LOG_BACK_PATH;cd $LOG_PATH && gzip access.logmv access.log.gz $LOG_BACK_PATH‘access_‘$(date +‘%d‘)‘.log.gz‘;kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`;

crontab -e

0 0 * * * /bin/bash /bin/bash /root/tools/crond/nginxlog.sh 1>/dev/null 2>&1

 

定时切割nginx日志