mysqldir=/usr/db/mysql infofiledir=/root/hmywork limitfile=limitmysql userfile=user_mysql #定义初始变量 while [ 1 ]; do sleep 10 #每隔10秒检查一次
for i in `cat ${infofiledir}/${userfile}` do now=`du ${mysqldir}/$i |tail -n 1 |awk '{print $1}'` #取得当前目录大小 limit=`grep $i ${infofiledir}/${limitfile}|awk '{print $2}'` #取得限额大小 if [ "$now" -gt "$limit" ]; #如果大于限额就执行下面的mysql语句 then mysql --user=MySql@AdminU_ser --password=***********< use mysql update db set insert_priv='N' ,update_priv='N', create_priv='N',Create_tmp_table_priv='N' where db='$i'; flush privileges ; EOF echo $i database full! `date`>;>;fulluser sed /`echo $i`/d $userfile >;tempfile fi done cp tempfile $userfile