每5分钟检查一次,如果不在线就重启
#!/bin/bash kafkaPid=`ps -ef|grep kafka|grep -v grep` if [ "$?" == "0" ];then echo "kafka is running " else echo "kafka not running" #启动 kafka echo "开始启动 kafka...." sh /home/kafka_2.11-1.0.0/bin/zookeeper-server-start.sh -daemon /home/sol/kafka_2.11-1.0.0/config/zookeeper.properties sleep 10; sh /home/kafka_2.11-1.0.0/bin/kafka-server-start.sh -daemon /home/sol/kafka_2.11-1.0.0/config/server.properties echo "kafka 启动成功" fi #crontab -e #*/5 * * * * /home/kafka_2.11-1.0.0/startkafka.sh > /tmp/startkafka.log 2>&1