#! /bin/shwhile :do ret=`/usr/bin/mysql -h localhost -u bill_www -psecret -e"use bill; select 1 \G;"|grep -v '*'|awk '/1:/{ print $2;}'` if [ $ret -eq 1 ]; then echo "is alive" exit else echo "is down" sleep 2 fidone
mysqladmin -hlocalhost -uroot -proot_pwd ping
#! /bin/shwhile ! /usr/bin/mysql -h localhost -ubill_www -psecret -b -e"use bill; select 1 \G;" &>/dev/null; do echo Dead sleep 2doneecho Alive