Skip to content

Instantly share code, notes, and snippets.

@uolter
Created April 3, 2014 11:28
Show Gist options
  • Save uolter/9952706 to your computer and use it in GitHub Desktop.
Save uolter/9952706 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Elastic Serarch Start and Stop Script
ES_HOME="/opt/elsearch/elasticsearch"
ES_USER="esearch"
PID=$(ps ax | grep elasticsearch | grep $ES_HOME | grep -v grep | awk '{print $1}')
#echo $PID
#exit 0
case "$1" in
start)
if [ -z "$PID" ]; then
echo "Starting Elasticsearch"
echo "Starting Elasticsearch" >> /var/tmp/elasticsearch
su -m $ES_USER -c "${ES_HOME}/bin/elasticsearch"
exit 0;
else
echo "Elasticsearch already running"
echo "Elasticsearch already running" >> /var/tmp/elasticsearch
exit 0;
fi
;;
stop)
if [ -n "$PID" ]; then
echo "Stopping Elasticsearch"
kill -15 ${PID}
echo "Stopped Elasticsearch"
exit 0;
else
echo "Elasticsearch is not running"
exit 0;
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment