check memcached process and rest
2018-03-08 本文已影响15人
9682f4e55d71
#!/bin/sh
#check memcached process and restart if down
PATH=$PATH:/usr/bin/memcached
DATE=`date -d "today" +"%Y-%m-%d-%H:%M"`
#用ps命令查看memcached进程
MM=`ps -aux |grep "memcached" |grep "13250" |grep -v "grep" |wc -l`
#if语句判断进程是否存在,如果不存在,输出日志记录并重启memcached服务
if [ "$MM" == "0" ]; then
echo "$DATE The memcached is problem and restart" >> /tmp/memcached_check.logs
/usr/bin/memcached -m 1024 -p 13250 -d -u nobody
else
echo "$DATE The memcached is ok" >>/tmp/memcached_check.logs
fi