-
run.sh
#!/bin/bash
cd /home/java_projects/yh_oa_api/
nohup java -jar yh_oa_api.jar --spring.profiles.active=dev --server.port=9023 > /dev/null 2>&1 &
echo "yh_oa_api.jar run successfully!"
-
stop.sh
#!/bin/bash
echo "search [yh_oa_api.jar] process ......"
pid=`ps -ef | grep "yh_oa_api.jar" | grep -v grep | awk '{print $2}'`
if [[ pid>0 ]]; then
echo "Process [ yh_oa_api.jar ] is runing , PID = $pid ;"
echo "Now Will Kill Process PID = $pid ;"
result=`kill -9 $pid`
else
echo "Process [ yh_oa_api.jar ] stop success! ;"
fi
-
restart.sh
#!/bin/bash
source /etc/profile
# 要发布的jar包名称
NEW_JAR='yh_oa_api.jar'
# 停止正在运行的jar包
pid=`ps -ef|grep $NEW_JAR| grep -v grep| awk '{print $2}'`
echo "部署前的pid进程 :$pid"
# 关闭已经启动的jar进程
if [ -n "$pid" ]
then
kill -9 $pid
else
echo "进程没有启动"
fi
# cd到jar包目录
cd /home/java_projects/yh_oa_api
# 启动
nohup java -agentpath:/tmp/cdbg_java_agent.so -jar $NEW_JAR --spring.profiles.active=dev --server.port=9023 >/dev/null 2>&1 &
echo "脚本执行完毕"
pid=`ps -ef | grep $NEW_JAR | grep -v grep | awk '{print $2}'`
# 检验进程是否启动
if [ -n "$pid" ]
then
echo "部署后的pid进程 :$pid"
echo "启动成功"
else
echo "进程没有启动"
fi