Nginx日志切割

#!/bin/sh
logpath="/data4/logs/"
newlogpath="/data4/logs/"`date +%Y/%m`
mkdir -p $newlogpath

cd $logpath
for filename in `ls *.log`
do
    mv $filename $newlogpath'/'$filename`date +%Y%m%d`'.log'
done

/usr/local/nginx/sbin/nginx -s reload

cp /tmp/logs/php-fpm.log $newlogpath'/php-fpm.log'`date +%Y%m%d`'.log'
echo '' >/tmp/logs/php-fpm.log

cp /tmp/logs/php-fpm.slow.log $newlogpath'/php-fpm.slow.log'`date +%Y%m%d`'.log'
echo '' >/tmp/logs/php-fpm.slow.log

cp /data/mysql_log/sql.slow.log $newlogpath'/sql.slow.log'`date +%Y%m%d`'.log'
echo '' >/data/mysql_log/sql.slow.log



你可能感兴趣的:(Nginx日志切割)