欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Nginx日志分割脚本

程序员文章站 2023-12-29 15:25:04
...
#/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}`

 

上一篇:

下一篇: