shell脚本监测进程并重启

本人实例:

#!/bin/bash

ps -ef | grep elastic | grep -v grep
if [ $? -ne 0 ]
then
echo "start process......"
echo 1 > /proc/sys/vm/drop_caches
cd /data/soft/elasticsearch-6.4.0/bin/
su elsearch
./elasticsearch -d
else
echo "runing......"
fi

这是检测搜索引擎 elastic 的脚本


#!/bin/bash

ps -ef | grep mysqld | grep -v grep
if [ $? -ne 0 ]
then
echo "start process......"
/etc/rc.d/init.d/mysqld start
else
echo "runing......"
fi

这是检测mysql 进程的 脚本

相关推荐