监控redis进程,如果没有自动重启

监控redis进程,如果没有自动重启

#Time:2016-01-22
#Version:1.0

#Author:chh-huang

#设置环境变量
source /etc/profile
#source ~/.bash_profile

# 日志输出
redisMonitorLog=/tmp/redisMonitor.log

# redis进程

redis_status=`ps -ef | grep redis|grep "redis-server"|grep -v grep|awk '{print $2}'`

#设置时间
monitor_date=`date`

#判断wasce是否工作
if [[ $redis_status ]]; then
echo -e '##### redis is work, thx god !!! #####'>>$redisMonitorLog
else
echo -e "##### redis isn't work, restart now !!! #####">>$redisMonitorLog
/etc/init.d/redisd stop
/etc/init.d/redisd start
fi

原文地址:https://www.cnblogs.com/paul8339/p/5349776.html