diff --git a/scripts/gateway-watchdog.sh b/scripts/gateway-watchdog.sh index 30200c7..83d4f5e 100755 --- a/scripts/gateway-watchdog.sh +++ b/scripts/gateway-watchdog.sh @@ -16,10 +16,11 @@ export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:$PATH" # === flock 防并发 === LOCK_FILE="/tmp/gateway-watchdog.lock" -exec 9>"$LOCK_FILE" -if ! flock -n 9; then +# macOS 无 flock,用 mkdir 做简易锁 +if ! mkdir "$LOCK_FILE" 2>/dev/null; then exit 0 fi +trap 'rmdir "$LOCK_FILE" 2>/dev/null' EXIT # === 配置 === CHECK_WINDOW=120 # 检查最近多少秒的日志