#修改默认内存大小配置文件/home/es/elasticsearch-8.2.0/config/jvm.options
if ps -ef | grep -v grep | grep elasticsearch > /dev/null; then
echo "ES服务正在运行."
current_time=$(date +"%H:%M")
if [[ $current_time == 00:00 ]]; then
echo "现在是$current_time点,开始重启ES服务"
#export ES_HEAP_SIZE="-Xms2g -Xmx2g"
ps aux | grep elasticsearch | grep -v grep | awk '{print $2}' | xargs kill -9
su - es -c '/home/es/elasticsearch-8.2.0/bin/elasticsearch -d'
if ps -ef | grep -v grep | grep elasticsearch > /dev/null; then
echo "ES服务重启成功."
else
echo "重启ES服务失败."
fi
else
echo "现在是$current_time,忽略重启"
fi
else
echo "ES服务未启动,开始启动"
#export ES_HEAP_SIZE="-Xms2g -Xmx2g"
su - es -c '/home/es/elasticsearch-8.2.0/bin/elasticsearch -d'
#cd ~
#cd elasticsearch-8.2.0
#./bin/elasticsearch -d
if ps -ef | grep -v grep | grep elasticsearch > /dev/null; then
echo "ES服务重启成功."
else
echo "重启ES服务失败."
fi
fi
最后修改:2024 年 04 月 28 日
© 允许规范转载