#!/bin/bash # Define an array of JAR files to run jars=("bonus-auth.jar --spring.config.location=file:auth_bootstrap.yml" "bonus-gateway.jar --spring.config.location=file:gateway_bootstrap.yml" "bonus-system.jar --spring.config.location=file:system_bootstrap.yml" "bonus-gen.jar --spring.config.location=file:gen_bootstrap.yml" "bonus-job.jar --spring.config.location=file:job_bootstrap.yml" "bonus-file.jar --spring.config.location=file:file_bootstrap.yml" "bonus-visual-monitor.jar --spring.config.location=file:visual_bootstrap.yml" "bonus-face.jar --spring.config.location=file:face_bootstrap.yml") # 遍历数组并检查每个JAR文件的进程 for jar_with_args in "${jars[@]}"; do # 提取JAR文件名(不包括参数) jar=$(echo $jar_with_args | awk '{print $1}') # 检查进程是否启动 echo "原应用程序1 $jar " pids=$(pgrep -f $jar || true) echo "原应用程序2 $jar " if [ -n "$pids" ]; then echo "$jar is running with PID(s): $pids" # 杀死进程 for pid in $pids; do kill -9 $pid if [ $? -eq 0 ]; then echo "Process $pid for $jar killed successfully" else echo "Failed to kill process $pid for $jar" fi done else echo "$jar is not running" fi done