4
Q:

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
1

New to Communities?

Join the community