#!/bin/bash # 定义一个函数来停止每个服务器的 screen 会话 stop_server() { server_name=$1 echo "Stopping $server_name" # 如果存在具有相同名称的 screen 会话,将其终止 existing_session=$(screen -ls | grep -w "$server_name") if [ -n "$existing_session" ]; then echo "Terminating screen session for $server_name" screen -S "$server_name" -X quit else echo "No screen session found for $server_name" fi } # 列出所有服务器目录 server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset") # 停止每个服务器的 screen 会话 for server_dir in "${server_dirs[@]}"; do stop_server $server_dir done