Check and fix mysql database tables
01 #! /Bin/sh02 # code by scpman03 # function: Check and fix mysql database table 04 # Add the script to the schedule. When the script is executed, it will read the database, list all the tables to be repaired, and run the timer to start the repair. 05 # record the damaged tables during the repair process. After the repair is completed, send an email to notify the damaged tables. 06fix_logs = '/tmp/fix. log '07user = ''08pass = ''09check _ fix () 10 {11 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 "'12echo start' date '> $ fix_logs13for dbname in $ dblist14do15echo $ dbname16for tb_name in'/usr/ bin/find/usr/dlm_db/mysql/$ dbname-type f | awk-F '/''{print $ NF}' | awk-F '. ''{print $1} '| sort-17u '18do19mysql-u $ user-p $ pass $ dbname <fff> $ fix_logs20check table $ tb_name; 21 repair table $ tb_name; 22FFF23done24done25echo 'date' done >>$ fix_logs26} 27send_logs () 28 {29 msgip = 10.0.7.4430IP = 'cat/etc/rc. conf | grep-E "ifconfig _ [em1 | bce1]" | awk '{print "IP: "$2} '| sed-n 1 P' 31fix _ info = 'grep-rE" Error | start | done "$ fix_logs' 32/usr/bin/logger-p local1.info -h $ msgip "the services: $ IP mysql_table_fix_info: $ fix_info "33} 34check_fix35send_logs