标签:erro find %s for time tmp access nginx log 针对
原来网上也有很多nginx分割日志的方法,发现都是针对access和error两个日志,今天完善一下,多项目多日志循环处理。#!/bin/bash
# This script run at 00:00
DATA_TIME=$(date +%F-%H:%M:%S)
# The Nginx logs path
nginx_log="/data/logs/nginx"
# Backup logs path
logs_path="/data/logs/cut_nginx_logs"
pid=$(cat /data/server/nginx/nginx.pid)
[ -d $logs_path ] || mkdir -p $logs_path
for f in $(find $nginx_log/ -type f);
do
echo ${f} > /tmp/tmp_log_name.txt
mv ${f} ${logs_path}/$(awk -F"/" ‘{print $NF}‘ $(echo /tmp/tmp_log_name.txt))_${DATA_TIME}.log;
done
kill -USR1 ${pid}
然后加入计划任务
crontab -e
00 00 * bash /data/script/cut_nginx_log.sh
标签:erro find %s for time tmp access nginx log 针对
原文地址:http://blog.51cto.com/hello80/2329043