es开机启动脚本

vim /etc/rc.d/init.d/elasticsearch

!/bin/bash

chkconfig:2345 80 05

description:mystart service

RETVAL=0
start(){
export JAVA_HOME=/usr/local/services/jdk1.8.0_91
echo -n "start elasticsearch"
su - user_00 -l -c ' /usr/local/services/elasticsearch-2.3.1/bin/elasticsearch -d'
}
stop(){
echo -n "stop elasticsearch"
pid=ps aux|grep elasticsearch-2.3.1|grep -v grep|awk '{print $2}'
kill -9 $pid
}
case $1 in
start)
start
;;
stop)
stop
;;
esac
exit $RETVAL

添加开机启动:
chkconfig --add elasticsearch

你可能感兴趣的:(es开机启动脚本)