Files
notes/resource/脚本/jar 包启动脚本.md
T
2026-03-01 01:43:46 +08:00

706 B

#!/bin/bash

pids=$(pgrep -f "community_demo-0.0.1-SNAPSHOT.jar")
if [ -n "$pids" ]; then
  echo "[INFO] Stopping old community_demo process(es): $pids"
  kill -15 $pids
  sleep 2
  pids_again=$(pgrep -f "community_demo-0.0.1-SNAPSHOT.jar")
  if [ -n "$pids_again" ]; then
    echo "[WARN] Force killing process(es): $pids_again"
    kill -9 $pids_again
  fi
fi
SCRIPTDIR="$( cd "$( dirname "$0"  )" && pwd  )"
echo "[INFO] Script directory: $SCRIPTDIR"
echo "[INFO] Starting new community_demo process..."
nohup java -jar /opt/community/community_demo-0.0.1-SNAPSHOT.jar >> /opt/community/logs/nohup.log 2>&1 &
echo "[INFO] Process started with PID: $!"
tail -f /opt/community/logs/nohup.log