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. NodejS---require的机制

    假设Y是路径,X是文件名或目录名,当 Nodejs 遇到 require(Y+X) 时,按照下面的顺序处理: 1.如果 X 是核心模块(例如:require("http")) a. ...

  2. SQL Server批量备份数据库

    --批量备份数据库201911 --开启文件夹权限 GO SP_CONFIGURE RECONFIGURE GO SP_CONFIGURE RECONFIGURE GO DECLARE ), ), ) ...

  3. Python中将(字典,列表等)变量格式化成字符串输出

    比如原始的List变量的值是这种: [{"]}] 而想要将其输出为带缩进的,树状的,很漂亮的效果,那么可以通过这样的方法: import json #demoDictList is the ...

  4. js __proto__ 和prototype的联系

    1.Javascript中所有的对象都是Object的实例,并继承Object.prototype的属性和方法,也就是说,Object.prototype是所有对象的爸爸.(个人感觉搞清楚这一点很重要 ...

  5. Nginx反向代理后应用程序获取客户端真实IP

    Nginx反向代理后,Servlet应用通过request.getRemoteAddr()取到的IP是Nginx的IP地址,并非客户端真实IP,通过request.getRequestURL()获取的 ...

  6. 关于SVN的405错误Server sent unexpected return value (405 Method Not Allowed)的解决办法

    一大早上捣鼓项目提交的时候出现这个错误: svn:server sent unexpected return value 405 method not allowed 百度了很多解决办法都没有解决,看 ...

  7. python多媒体文件抽取

    多文件抽取有:只获取url,或直接下载,下面是怎么将数据下载下来,并显示进度. 本节主要介绍urllib模块提供的urlretrieve()函数.urlretrieve()方法直接将远程数据下载到本地 ...

  8. 配置传统vlan间路由

    S1#SH RUN spanning-tree mode pvst ! interface FastEthernet0/1 switchport access vlan 10 switchport m ...

  9. NOIp2015D1T3 斗地主【暴搜】

    题目传送门 刚开始读到题目的时候,非常懵逼,非常崩溃,写着写着呢,也有点崩溃,细节有点多. 这个做法呢,只能过掉官方数据,洛谷上好像有加强版,只能得$86$分,就没有管了. 大概说一下思路: 暴力搜索 ...

  10. flask_alembic操作

    HOSTNAME = '127.0.0.1' PORT = 3306 DATABASE = 'first_sqlalchemy_demo' USERNAME = 'root' PASSWORD = ' ...