check memcached process and restart if down

#!/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
    原文作者:明天的明abc
    原文地址: https://www.jianshu.com/p/4d3f0a702f85
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞