REDIS=/usr/local/bin/redis-cli REDIS_STATUS=1 CHECK_TIME=3 function check_redis_status() { $REDIS PING >/dev/null 2>&1 if [ $? = 0 ]; then REDIS_STATUS=1 else REDIS_STATUS=0 fi return $REDIS_STATUS } while [ $CHECK_TIME -ne 0 ]; do let "CHECK_TIME -= 1" check_redis_status if [ $REDIS_STATUS = 1 ]; then REDIS_STATUS=1 exit 0 fi if [ $REDIS_STATUS -eq 0 ] && [ $CHECK_TIME -eq 0 ]; then /etc/init.d/keepalived stop exit 1 fi sleep 1 done
时间: 2024-10-11 08:34:09