#!/bin/bash #脚本对日志文件进行切割 #脚本需要crontab 每天定时执行 #Nginx 日志文件的存放路径 logs_path="/../logs/" mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/ echo "-----------------" mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log kill -USER1 `cat /../nginx/nginx.pid`
crontab -e
00 00 * * * /bin/bash /…/…/cut_nginx_log.sh