• ELK的启动脚本


    作者:邓聪聪

    方便自己的应用,制作一个elk的自启动脚本

    #!/bin/sh
    PATH=$PATH
    . /etc/init.d/functions
    
    start() {
        if [ `ps aux|grep elasticsearch | grep -v grep|wc -l` -eq 0 ];then
            if [ `whoami` == elk ];then
              /elk/elasticsearch-6.3.0/bin/elasticsearch -d
              action "start elasticsearch:" true
            else
              su - elk -c "/elk/elasticsearch-6.3.0/bin/elasticsearch -d"
              if [ $? -eq 0 ];then
                 touch /var/lock/subsys/elasticsearch
                 action "start elasticsearch:" true
              else
                 action "start elasticsearch:" false
              fi
            fi
        else
            echo "elasticsearch is running"
        fi
    }
    stop() {
        if [ `ps aux|grep elasticsearch | grep -v grep|wc -l` -eq 0 ];then 
            echo "No running program found elasticsearch"
        else
            ps_uid=`ps aux|grep elasticsearch | grep -v grep | awk '{print $2}'`
            kill -9 $ps_uid
            [ $? -eq 0 ] && rm -f /var/lock/subsys/elasticsearch
            action "elasticsearch is stop" true
        fi
    }
    restart() {
        stop
        start
    }
    case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Use $0 start|stop|restart"
    esac
  • 相关阅读:
    机器学习的数学基础
    Numpy + matplotlib + pandas 用法示例
    笔记:《ZeroMQ》
    Bash 常用快捷键
    Python网络爬虫
    Bash-Script 应用案例
    Bash-Script 语法详解
    ADB的使用
    ROS概述
    架构风格
  • 原文地址:https://www.cnblogs.com/dengcongcong/p/10992294.html
Copyright © 2020-2023  润新知