elasticsearch设置执行脚本并添加开机启动

/etc/init.d目录下新建文件elasticsearch

#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch export JAVA_HOME=/usr/java/jdk1.8.0_112
export JAVA_BIN=/usr/java/jdk1.8.0_112/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH case "$1" in
start)
su lyt<<!
cd /home/lyt/dev-repo/elk5/elasticsearch-5.6.9
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su lyt<<!
cd /home/lyt/dev-repo/elk5/elasticsearch-5.6.9
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac exit $?

保存退出,赋予执行权限

chmod +x elasticsearch 

添加到开机启动任务

chkconfig -add elasticsearch

如果不设置开机启动的话,也可以使用service elasticsearch start/stop/restart来操作

/etc/init.d目录下新建文件elasticsearch

  1.  
    #!/bin/sh
  2.  
    #chkconfig: 2345 80 05
  3.  
    #description: elasticsearch
  4.  
     
  5.  
    export JAVA_HOME=/usr/java/jdk1.8.0_112
  6.  
    export JAVA_BIN=/usr/java/jdk1.8.0_112/bin
  7.  
    export PATH=$PATH:$JAVA_HOME/bin
  8.  
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  9.  
    export JAVA_HOME JAVA_BIN PATH CLASSPATH
  10.  
     
  11.  
    case "$1" in
  12.  
    start)
  13.  
    su lyt<<!
  14.  
    cd /home/lyt/dev-repo/elk5/elasticsearch-5.6.9
  15.  
    ./bin/elasticsearch -d
  16.  
    !
  17.  
    echo "elasticsearch startup"
  18.  
    ;;
  19.  
    stop)
  20.  
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
  21.  
    kill -9 $es_pid
  22.  
    echo "elasticsearch stopped"
  23.  
    ;;
  24.  
    restart)
  25.  
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
  26.  
    kill -9 $es_pid
  27.  
    echo "elasticsearch stopped"
  28.  
    su lyt<<!
  29.  
    cd /home/lyt/dev-repo/elk5/elasticsearch-5.6.9
  30.  
    ./bin/elasticsearch -d
  31.  
    !
  32.  
    echo "elasticsearch startup"
  33.  
    ;;
  34.  
    *)
  35.  
    echo "start|stop|restart"
  36.  
    ;;
  37.  
    esac
  38.  
     
  39.  
    exit $?

保存退出,赋予执行权限

chmod +x elasticsearch 

添加到开机启动任务

chkconfig -add elasticsearch

如果不设置开机启动的话,也可以使用service elasticsearch start/stop/restart来操作

原文:https://my.oschina.net/liuyuantao/blog/1798724

elasticsearch设置执行脚本并添加开机启动 (转)的更多相关文章

  1. centos7之添加开机启动服务/脚本

    一.添加开机启动脚本 #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to ...

  2. (转) CentOS 7添加开机启动服务/脚本

    CentOS 7添加开机启动服务/脚本 原文:http://blog.csdn.net/wang123459/article/details/79063703 一.添加开机自启服务 在CentOS 7 ...

  3. windows添加开机启动项

    http://www.cnblogs.com/jokey/archive/2010/06/17/1759370.html添加开机启动项(通过注册表) 例子:增加QQ开机启动项 第一步:找到注册表的启动 ...

  4. Linux 添加开机启动项的三种方法

    linux 添加开机启动项的三种方法. (1)编辑文件 /etc/rc.local 输入命令:vim /etc/rc.local 将出现类似如下的文本片段: #!/bin/sh## This scri ...

  5. ubuntu 添加开机启动服务

    新建umpserver.service [Unit] Description=UMPServer After=syslog.target network.target remote-fs.target ...

  6. centos7如何添加开机启动项?

    centos7提供开启服务启动的方式: 1.系统服务管理命令,如果是通过yum安装的软件,开机启动脚本,已经自动创建好了,直接执行如下命令 nginx.service后缀可以省略 systemctl ...

  7. 不同linux系统添加开机启动程序的命令

    see http://phpcj.org/blog/%E4%B8%8D%E5%90%8Clinux%E7%B3%BB%E7%BB%9F%E6%B7%BB%E5%8A%A0%E5%BC%80%E6%9C ...

  8. ubuntu16.04添加开机启动任务

    比如要把run-nexus.sh这个脚本制作成开机启动项. 系统工具->首选项->启动应用程序.添加该文件,即可.

  9. Centos 7 添加开机启动

    1.添加启动服务 添加docker开机启动服务 [root@localhost ~]# systemctl enable docker.serviceCreated symlink from /etc ...

随机推荐

  1. [SQL 高级查询运算符的用法 UNION (ALL),EXCEPT(ALL),INTERSECT(ALL) ]

    今天看到 三个查询运算符,给大家分享分享 为此我建立了两张表分别为 Articles 和  newArticles 我建立的时候,只建立了一张表 Articles   ,表 newArticles 是 ...

  2. 六、Jmeter中自动提取Http请求参数,并put到Map,然后进行MD5加密

    1.BeanShell PerOrocessor中的脚本 import src.com.csjin.qa.MD5.*;//个人jar包 import java.util.*; import java. ...

  3. 自定义可拖动的Toast

    package com.loaderman.toastdemo; import android.content.Context; import android.graphics.PixelFormat ...

  4. WPF 键盘全局接收消息

    1.========================================================================== 在c#中怎样禁用鼠标左键的使用,其实我们可以通 ...

  5. eclipse svn is already locked解决方案

    转: eclipse svn is already locked解决方案 2017年05月15日 22:21:54 Aaron莫言 阅读数:5867   版权声明:本文为博主原创文章,未经博主允许不得 ...

  6. 阶段3 3.SpringMVC·_06.异常处理及拦截器_2 SpringMVC异常处理之演示程序异常

    原来的index.jsp删除.新建一个 创建pages文件夹.再创建success.jsp页面 重新部署项目 把这个项目移除掉 加入新的项目 启动tomcat服务器 模拟异常 方法抛出异常给前端控制器 ...

  7. 小程序onLaunch事件的坑

    记一个小程序踩过的坑 小程序项目中app.js里面定义了globalData,即全局变量,里面定义了一个token字段 需求是这样的,每次进入小程序的时候需要检验该token有没有,没有就请求后台获取 ...

  8. Java通过字节分割字符串

    一.题目描述: 一道Java笔试题.将字符串按给定的字节数进行分割,输出分割后的字符串.要求汉字不能进行拆分,如“a中国”不能拆分成“a+中的一半”. 二.解题思路: 首先利用String类的subs ...

  9. java去除数组中的空值

    public String[] deleteArrayNull(String []string) { String []array = string; // 声明一个list List<Stri ...

  10. 【Linux开发】linux设备驱动归纳总结(三):6.poll和sellct

    linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...