Copy Code code as follows:
#!/bin/sh
#code by Scpman
#功能: Review and repair MySQL database tables
#将此脚本加到定时中, when the script executes, it reads the library, lists all the tables to be repaired, and then timings to start the repair
#修复过程中将损坏的表记录下来, after the repair is completed, the damaged table will be sent to the mail notification.
fix_logs= '/tmp/fix.log '
User= '
Pass= '
Check_fix ()
{
Dblist= '/usr/bin/find/usr/dlm_db/mysql/-type D | Grep-ve "Logs|_[1-9]|*bak|test" | Sed-e "s#/usr/dlm_db/mysql/# #g" '
echo start ' Date ' > $fix _logs
For dbname in $dblist
Todo
Echo $dbname
For Tb_name in '/usr/bin/find/usr/dlm_db/mysql/$dbname-type F | Awk-f '/' {print $NF} ' | Awk-f '. ' ' {print $} ' | Sort-
U '
Todo
Mysql-u$user-p$pass $dbname <<fff>> $fix _logs
Check table $TB _name;
Repair table $TB _name;
FFF
Done
Done
echo ' Date ' done>> $fix _logs
}
Send_logs ()
{
msgip=10.0.7.44
ip= ' cat/etc/rc.conf | Grep-e "Ifconfig_[em1|bce1]" | awk ' {print ' IP: ' $} ' | Sed-n 1p '
fix_info= ' grep-re ' error|start|done ' $fix _logs '
/usr/bin/logger-p local1.info-h $MSGIP "The Services: $IP mysql_table_fix_info: $fix _info"
}
Check_fix
Send_logs