cd /etc/init.d
touch elasticsearch
vim elasticsearch
#!/bin/bash
case $1 in
start)
cd /opt/module/elasticsearch-6.3.1
./bin/elasticsearch
echo "elasticsearch startup"
;;
stop)
es_pid=`ps -ef|grep elasticsearch|grep -v 'grep'|awk '{print $2}'`
for pid in $es_pid
do
kill -9 $pid
done
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps -ef|grep elasticsearch |grep -v 'grep'|awk '{print $2}'`
for pid in $es_pid
do
kill -9 $pid
done
echo "elasticsearch stopped"
cd /opt/module/elasticsearch-6.3.1
./bin/elasticsearch
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
chmod 755 elasticsearch
service elasticsearch start
shell 脚本 M-BM- 字符问题
解决方法: sed ‘s/\xc2\xa0/ /g’ -i 文件路径
sed -i 's/\xc2\xa0/ /g' elasticsearch