脚本如下:
#!/bin/bash
echo "------ 日志切I」start-------- "
LOGPATH=/var/log/nginx/access.log
BASEPATH=/data
BACKUPS_PATH=$BASEPATH/$(date -d yesterday +%Y%m%d%H%M).access.log
mv $LOGPATH $BACKUPS_PATH
touch $LOGPATH
kill -USR1 $(cat /run/nginx.pid)
echo "------ 日志切Qend--------- "