#!bin/bash user='root' passwd="123" host="192.168.192.156" mycmd="mysql -u$user -p$passwd -h $host" chkdb(){ list=($($mycmd -e "show slave status G"|egrep "Running|Bebind"|awk -F: '{print $2}')) if [ ${list[0]} = "Yes" -a ${list[2]} = "Yes" -a ${list[2]} -lt 120 ];then echo "mysql slave is ok" else echo "mysql replation is filed!!" fi } chkdb