elasticsearch设置执行脚本并添加开机启动 (转)
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
- #!/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来操作
原文:https://my.oschina.net/liuyuantao/blog/1798724
elasticsearch设置执行脚本并添加开机启动 (转)的更多相关文章
- centos7之添加开机启动服务/脚本
一.添加开机启动脚本 #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to ...
- (转) CentOS 7添加开机启动服务/脚本
CentOS 7添加开机启动服务/脚本 原文:http://blog.csdn.net/wang123459/article/details/79063703 一.添加开机自启服务 在CentOS 7 ...
- windows添加开机启动项
http://www.cnblogs.com/jokey/archive/2010/06/17/1759370.html添加开机启动项(通过注册表) 例子:增加QQ开机启动项 第一步:找到注册表的启动 ...
- Linux 添加开机启动项的三种方法
linux 添加开机启动项的三种方法. (1)编辑文件 /etc/rc.local 输入命令:vim /etc/rc.local 将出现类似如下的文本片段: #!/bin/sh## This scri ...
- ubuntu 添加开机启动服务
新建umpserver.service [Unit] Description=UMPServer After=syslog.target network.target remote-fs.target ...
- centos7如何添加开机启动项?
centos7提供开启服务启动的方式: 1.系统服务管理命令,如果是通过yum安装的软件,开机启动脚本,已经自动创建好了,直接执行如下命令 nginx.service后缀可以省略 systemctl ...
- 不同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 ...
- ubuntu16.04添加开机启动任务
比如要把run-nexus.sh这个脚本制作成开机启动项. 系统工具->首选项->启动应用程序.添加该文件,即可.
- Centos 7 添加开机启动
1.添加启动服务 添加docker开机启动服务 [root@localhost ~]# systemctl enable docker.serviceCreated symlink from /etc ...
随机推荐
- NodejS---require的机制
假设Y是路径,X是文件名或目录名,当 Nodejs 遇到 require(Y+X) 时,按照下面的顺序处理: 1.如果 X 是核心模块(例如:require("http")) a. ...
- SQL Server批量备份数据库
--批量备份数据库201911 --开启文件夹权限 GO SP_CONFIGURE RECONFIGURE GO SP_CONFIGURE RECONFIGURE GO DECLARE ), ), ) ...
- Python中将(字典,列表等)变量格式化成字符串输出
比如原始的List变量的值是这种: [{"]}] 而想要将其输出为带缩进的,树状的,很漂亮的效果,那么可以通过这样的方法: import json #demoDictList is the ...
- js __proto__ 和prototype的联系
1.Javascript中所有的对象都是Object的实例,并继承Object.prototype的属性和方法,也就是说,Object.prototype是所有对象的爸爸.(个人感觉搞清楚这一点很重要 ...
- Nginx反向代理后应用程序获取客户端真实IP
Nginx反向代理后,Servlet应用通过request.getRemoteAddr()取到的IP是Nginx的IP地址,并非客户端真实IP,通过request.getRequestURL()获取的 ...
- 关于SVN的405错误Server sent unexpected return value (405 Method Not Allowed)的解决办法
一大早上捣鼓项目提交的时候出现这个错误: svn:server sent unexpected return value 405 method not allowed 百度了很多解决办法都没有解决,看 ...
- python多媒体文件抽取
多文件抽取有:只获取url,或直接下载,下面是怎么将数据下载下来,并显示进度. 本节主要介绍urllib模块提供的urlretrieve()函数.urlretrieve()方法直接将远程数据下载到本地 ...
- 配置传统vlan间路由
S1#SH RUN spanning-tree mode pvst ! interface FastEthernet0/1 switchport access vlan 10 switchport m ...
- NOIp2015D1T3 斗地主【暴搜】
题目传送门 刚开始读到题目的时候,非常懵逼,非常崩溃,写着写着呢,也有点崩溃,细节有点多. 这个做法呢,只能过掉官方数据,洛谷上好像有加强版,只能得$86$分,就没有管了. 大概说一下思路: 暴力搜索 ...
- flask_alembic操作
HOSTNAME = '127.0.0.1' PORT = 3306 DATABASE = 'first_sqlalchemy_demo' USERNAME = 'root' PASSWORD = ' ...