启动java jar包
1.创建 restart.sh
echo "Restarting springboot Application"
pid=`ps -ef | grep target.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
kill -9 $pid
echo "closed process"$pid
fi
nohup java -jar ./target.jar > ./target.log 2>&1 &
可以直接执行cat+EOF 形式创建
cat > ./restart_spider.sh <<-'EOF'
echo "Restarting springboot Application"
pid=`ps -ef | grep target.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
kill -9 $pid
echo "closed process"$pid
fi
nohup java -jar ./target.jar > ./target.log 2>&1 &
EOF
2.替换jar名字
sed -i 's#target#spider-flow#g' restart_spider.sh
3.运行脚本
sh restart_spider.sh (spider可以换成自己的名字)