mysql bin日志文件清除脚本

#!/bin/sh
## 2007-11-6

DELLOG="/usr/local/logs/del-sqlbin.log.`date +%d`"
DELTMP="/usr/local/logs/del-sqlbin.tmp"
MAIL_ADDR="xxx@xxx.xx"
exec &>$DELLOG

DT=`date +'%Y-%m-%d %T'`
SINGLE=0
sleep 30

hostname
echo `date +'%Y-%m-%d %T'`
echo "EXEC>>"
echo "PURGE MASTER LOGS BEFORE '$DT';"
echo "PURGE MASTER LOGS BEFORE '$DT';" >$DELTMP
mysql -uroot -pxxx <$DELTMP

if [ $? = 0 ];then
        echo "Purge master logs sucess!"
else
        echo "Purge master logs failure!"
        SINGLE=1
fi
echo "--------------------------------"
echo

if [ $SINGLE = 1 ];then
        mail -s "Purge_master_logs_err" $MAIL_ADDR <$DELLOG
fi
Trackback

no comment untill now

Add your comment now

切换到手机版