Redis端口存活檢測

計劃任務redis

crontab -e 

*/1 * * * *  sudo sh /root/redis/redis_cluster/7003-cron.sh

腳本tcp

#!/bin/sh

redis=`netstat -an | grep ":7003" | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l`

if [ $redis -eq 0 ];then
      #端口被佔用執行以下
      sudo  /root/redis/redis_cluster/start_all.sh.sh
  else
      #端口被佔用提示以下
          echo "運行正常!"
fi

啓動腳本ide

cd /root/redis/redis_cluster/7000
/usr/local/bin/redis-server redis.conf
cd /root/redis/redis_cluster/7001
/usr/local/bin/redis-server redis.conf
cd /root/redis/redis_cluster/7005
/usr/local/bin/redis-server redis.conf
相關文章
相關標籤/搜索