Nginx日志分割脚本
程序员文章站
2023-12-29 15:21:34
...
#/bin/bash LOGS_PATH="/usr/local/nginx/logs" YESTERDAY=$(date -d "yesterday" +%Y%m%d) pid_path="/usr/local/nginx/logs/nginx.pid" cd $LOGS_PATH for log_name in ` ls *.access.log ` do mv ${LOGS_PATH}/${log_name} ${LOGS_PATH}/${log_name}_${YESTERDAY}.log done kill -USR1 `cat ${pid_path}`