Elasticsearch启动停止脚本
进入 elasticsearch/bin 直接运行下面的内容, 生成脚本
tee ./server.sh <<-'EOF'
#! /bin/bash
cd $(cd "$(dirname "$0")"; pwd)/../
ES_HOME=$PWD
APP_NAME=elasticsearch
PIDFILE=$ES_HOME/bin/elasticsearch-server.pid
#echo "elasticsearch-server script"
# 使用方式
usage() {
echo "Usage: ./service.sh [start | stop | restart | status]"
exit 1
}
# 判断当前服务是否已经启动的函数
is_exist() {
#echo "run is_exist function"
pid=`ps -ef | grep Elasticsearch | grep -v grep | awk '{print $2}'`
if [ -z "${pid}" ]; then
#echo "pid is null."
echo "The $APP_NAME service does not exist, and the status information is: $APP_NAME is not running."
return 1
else
#echo "pid is not null."
echo "$APP_NAME already exists and this service status information is: $APP_NAME is running.( pi