mysql--bin日志文件清除脚本
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
mysqlpath=/usr/local/mysql/bin/mysql
LOGPATH=/var/log/mysql_log
if [ -d "$LOGPATH" ];then
:
else
mkdir $LOGPATH
fi
DELLOG="$LOGPATH/del-sqlbin.log.$(date +%d)"
DELTMP="$LOGPATH/del-sqlbin.tmp"
MAIL_ADDR=""
DT=$(date +%Y-%m-%d --date='14 day ago')
SINGLE=0
sleep 10
echo $(date +'%Y-%m-%d %T')
echo "PURGE MASTER LOGS BEFORE '$DT';"
echo "PURGE MASTER LOGS BEFORE '$DT';" > $DELTMP
$mysqlpath -uroot < $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
阅读(1484) | 评论(0) | 转发(0) |