memcache停止后自动重启的解决办法

废话不多说,直接上命令

#!/bin/sh
#check memcached process and restart if down
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#用ps命令查看memcached进程
MM=`ps -aux |grep "memcached" |grep "11211" |grep -v "grep" |wc -l`
#if语句判断进程是否存在,如果不存在,输出日志记录并重启memcached服务
if [ "$MM" == "0" ]; 
then
echo "At time:$(date) :Nginx is stop .">> /var/log/memcached_messages
/etc/init.d/memcached start
else
#echo "At time:$(date) :Nginx is ok .">> /var/log/memcached_messages
exit
fi

发布者:梧桐细雨,转转请注明出处:https://www.binbinbiji.com/jianzhanjiaoliu/2251.html

发表评论

邮箱地址不会被公开。 必填项已用*标注

蜀ICP备14017386号-13