Files
spdm-backend/system/src/main/resources/bin/65/stop.sh

32 lines
690 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Spring Boot 项目强制停止脚本
JAR_NAME="system-0.0.1-SNAPSHOT.jar"
# 函数定义获取运行中的进程ID
get_running_pid() {
ps -ef | grep "${JAR_NAME}" | grep -v "grep" | awk '{print $2}'
}
# 获取进程ID
PID=$(get_running_pid)
# 检查进程是否存在
if [ -z "${PID}" ]; then
echo "项目未在运行中,无需停止"
exit 0
fi
# 强制停止进程
echo "正在强制停止项目... PID: ${PID}"
kill -9 "${PID}"
# 检查是否成功停止
sleep 5
if [ -z "$(get_running_pid)" ]; then
echo "项目已强制停止成功"
exit 0
else
echo "ERROR: 进程终止失败请手动检查ps -ef | grep ${JAR_NAME}"
exit 1
fi