linux环境springcloud服务jar包启动停止脚本
1. 启动脚本
#!/bin/bash
pid=`ps -ef|grep jar-name.jar | grep -v grep | awk '{print $2}'`
if [ $pid ];
then
echo "服务已在运行,不可重复启动"
else
nohup java -Xmx2g -Xms2g -Djava.security.egd=file:/dev/./urandom -jar /root/app/jar/jar-name.jar --spring.cloud.bootstrap.location=/root//app/jar/config/ >/dev/null 2>&1 &
pid=`ps -ef|grep jar-name.jar | grep -v grep | awk '{print $2}'`
echo "启动成功 pid: $pid "
fi
2. 停止脚本
#!/bin/bash
pid=`ps -ef|grep jar-name.jar | grep -v grep | awk '{print $2}'`
echo "pid: $pid "
if [ $pid ];
then
echo "pid: $pid"
kill -9 $pid
echo "服务停止成功"
else
echo "未找到对应服务"
fi
3. 注意事项
1)调整文件属性
chmod +x start.sh
chmod +x stop.sh
2)文件编码 如果是windows编辑后上传,注意脚本编码修改为Unix(LF) UTF-8,
|