#!/bin/bash
echo '################### 1. 检查8081端口是否被占用...'
pid_blog=`netstat -tunpl | grep 8081|awk '{printf $7}'|cut -d/ -f1`
if [ "$pid_blog" != "" ];
then
echo '################### 8081端口被占用'
kill -9 "$pid_blog"
echo "###################" $pid_blog '进程已被杀死'
else
echo "################### 端口未被占用"
fi
echo '################### 2. 后台运行jar包...'
for file in `ls`
do
if [ "${file##*.}"x = "jar"x ]
then
nohup java -jar $file --server.port=8081 > ./nohup.out &
break
fi
done
echo '🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥jar包部署结束a🔥🔥🔥🔥🔥🔥🔥🔥'
使用方式
- 新建build.sh
- jar包放在相同的文件夹下
./build.sh
网友评论