#!/bin/bash savepath_log=‘/opt/apps/nginx/nglogs‘ nglogs=‘/opt/apps/nginx/logs‘ mkdir -p ${savepath_log}/$(date +%Y)/$(date +%m) mv $nglogs/error.log ${savepath_log}/$(date +%Y)/$(date +%m)/error.$(date +%Y%m%d).log mv $nglogs/access.log ${savepath_log}/$(date +%Y)/$(date +%m)/access.$(date +%Y%m%d).log kill -USR1 `cat /opt/apps/nginx/logs/nginx.pid`
加入任务计划
#Nginx日志切割
0 0 * * * source /etc/profile && /bin/bash /opt/apps/nginx/cut_log.sh>/root/loh.bk 2>&1
时间: 2024-12-26 20:24:18