01
#! /Bin/sh
02
# Code by scpman
03
# Function: Check and fix mysql database tables
04
# Add the script to the timer. When the script is executed, it will read the database, list all the tables to be repaired, timing them, and start fixing.
05
# The damaged table is recorded in the repair process. After the repair is completed, the damaged table is sent to an email.
06
Fix_logs = '/tmp/fix. Log'
07
User =''
08
Pass =''
09
Check_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 "'
12
Echo start 'date'> $ fix_logs
13
For dbname in $ dblist
14
Do
15
Echo $ dbname
16
For tb_name in '/usr/bin/find/usr/dlm_db/mysql/$ dbname-type f | awk-F'/''{print $ NF}' | awk-F '. ''{print $1} '| sort-
17
U'
18
Do
19
Mysql-u $ user-p $ pass $ dbname <fff> $ fix_logs
20
Check table $ tb_name;
21
Repair table $ tb_name;
22
FFF
23
Done
24
Done
25
Echo 'date' done> $ fix_logs
26
}
27
Send_logs ()
28
{
29
Msgip = 10.0.7.44
30
IP = 'cat/etc/rc. conf | grep-E "ifconfig _ [em1 | bce1]" | awk '{print "IP:" $2}' | sed-n 1 P'
31
Fix_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
}
34
Check_fix
35
Send_logs