linux shell获取show slave status方法

linux shell获取show slave status方法

#!/bin/bash
array=($(mysql -u数据库账号 -p数据库密码  -e "show slave status\G"|grep "Running" |awk '{print $2}'))
 if [ "${array[0]}" == "Yes" ] && [ "${array[1]}" == "Yes" ]
          then
            echo "slave is OK"
       else
             echo "slave is wrong"
    fi

别忘记输入数据库账号和密码