how to restart elasticsearch service code example
Example 1: how to restart elasticsearch node
sudo service elasticsearch.service status -l
sudo service elasticsearch.service restart
Restart Elasticsearch services ^^
Example 2: bash script to restart elasticsearch
#!/bin/sh
RESTART="/etc/init.d/elasticsearch restart"
SERVICE="elasticsearch"
LOGFILE="/var/log/elasticRestart.log"
ps -ef | grep elastic | grep -v grep > /dev/null
if [ $? -eq 0 ]
then
/etc/init.d/elasticsearch restart >> /var/log/elasticRestart.log
echo "Elasticsearch relaunched at $(date)" >> /var/log/elasticRestart.log
else
echo "Elasticsearch is running $(date)" >> /var/log/elasticRestart.log
fi