脚本内容
#!/bin/sh
#check memcached process and restart if down
DATE=`date -d "today" +"%Y-%m-%d-%H:%M"`
#用ps命令查看memcached进程
MM=`ps aux |grep "memcached" |grep "11211" |grep -v "grep" |wc -l`
#if语句判断进程是否存在,如果不存在,输出日志记录并重启memcached服务
if [ "$MM" == "0" ];
then
echo "$DATE The memcached is problem and restart" >> /root/memcached_check.logs
memcached -d -m 50 -u cloud -p 11211 -c 1024
#wdcp的memcached路径重启命令,语句可以通过ps aux|grep "memchched"
/etc/init.d/memcached start
fi