1、neo4j服务为例
vim neo4jwatch.sh
#!/bin/bash while true; do time1=$(date "+%Y-%m-%d %H:%M:%S") echo $time1 count=`ps -ef|grep /opt/neo4j-community-3.4.7-kl | grep -v grep` if [ "$?" != "0" ];then echo ">>>>no cdss neo4j,run it" echo ">>>>restart cdss neo4j now !" /opt/neo4j-community-3.4.7-kl/bin/neo4j start else echo ">>>>cdss neo4j is runing..." fi sleep 60 done
运行:
nohup sh neo4jwatch.sh >> /home/bijl/dev/restart/logs/check_and_restart.log 2>&1