• Linux 检查应用不在现就重启


    每5分钟检查一次,如果不在线就重启

    #!/bin/bash
    count=`ps axu | grep kafka_2.11-1.0.0|grep -v grep|wc -l`
    echo "process count => "$count
    if [ "$count" != 0 ];then
            echo "kafka is running "
    else
            echo "kafka not running"
            #启动 kafka
            echo "开始启动 zookeeper...."
            sh /home/sol/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; 
            echo "开始启动 kafka...."
            sh /home/sol/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/sol/startkafka.sh > /tmp/startkafka.log 2>&1 
    
    #startkafka.sh 不能放在 kafka_2.11-1.0.0 里面,否则 grep kafka_2.11-1.0.0 的count 会有数量
    #grep kafka_2.11-1.0.0 最好不要写 grep kafka ,防止 count 有值

    红字 kafka 可以换成 tomcat 等其它应用

  • 相关阅读:
    database design
    django bulk create user
    mysql basic
    install mysql
    django apache httpd windows
    django apache httpd centos
    python mail smtplib
    compile c cpp with cl.exe in vim
    Remote Access to IPython Notebooks via SSH
    calculate traffic by snmpwalk for mrtg
  • 原文地址:https://www.cnblogs.com/vipsoft/p/14470040.html
Copyright © 2020-2023  润新知