1.centos服务器配置发送邮件功能
参考此链接https://developer.aliyun.com/article/765549
2.创建目录和脚本文件
mkdir /shell
vim /shell/restart.sh输入以下内容
#!/bin/bash
ps -ef | grep redis | grep -v grep
if [ $? -ne 0 ];then
echo "redis is start"
redis-server /data/redis/etc/redis.conf
echo "120.79.*.* redis server start" |mailx -v -s "120.79.*.* redis server start" 1977107948@qq.com
else
echo "redis is running"
fi
3.设置shell脚本定时执行
crontab -e添加截图的内容(每两分钟执行一次脚本)