This commit is contained in:
yuzchen 2024-01-24 08:52:35 +08:00
parent b6643a0933
commit a88c9812bf
1 changed files with 8 additions and 5 deletions

View File

@ -1,12 +1,15 @@
#!/bin/sh
# 找到Springboot项目对应的进程id
pid=`ps -ef | grep demo4bonus-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
$P_ID=`ps -ef | grep demo4bonus-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
# 如果该项目已经在服务器上启动则kill掉
echo “原应用程序进程id$pid
if [ -n "$pid" ]
then
kill -9 $pid
if [ "$P_ID" == "" ]; then
echo "===service process doest not exist"
else
kill -9 $P_ID
echo "service killed success"
fi
echo "授权"
# 让root用户对jar包持有读执行的权限
chmod 777 /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar
@ -15,5 +18,5 @@ echo "执行"
# cd /opt/webapps/
# 目标服务器后台方式启动jar包
#nohup java -jar demo4bonus-0.0.1-SNAPSHOT.jar &
nohup /usr/local/jdk-17.0.9/bin/java -jar demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
nohup /usr/local/jdk-17.0.9/bin/java -jar /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
echo "启动成功"