#!/bin/bash # 询问用户输入端口 read -p "请输入端口号 (默认56800): " port # 验证端口输入,如果为空或非数字则使用默认值 if [[ -z "$port" ]] || ! [[ "$port" =~ ^[0-9]+$ ]]; then port=56800 fi # 设置环境变量 export Z_PORT=$port # 循环运行程序 while true; do ./linux/backend/backend echo "程序退出,正在重启..." sleep 1 done