本文共 575 字,大约阅读时间需要 1 分钟。
一、编写定时切割nginx日志脚本 脚本名称:/usr/local/nginx/sbin/cut_nginx_log.sh 脚本内容: #!/bin/bash #this script run at 00:00 #the nginx logs path logs_path="/usr/local/nginx/logs" mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday")+"%m" )/ mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" + "%m")/access_$(date -d "yesterday" +"%Y%m%d").log kill -USR1 `cat /usr/local/nginx/nginx.pid` 设置crontab,每天凌晨切割nginx访问日志 00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_log.sh 二、 转载于:https://www.cnblogs.com/xialiaoliao0911/p/7524020.html