Files
tools/scripts/check_tunnel_v3.sh

21 lines
760 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 简单轮程宑控脚本
# 每隔几秒检查一次轮程,轮程消失则执行命令
# ==================== 配置区域(只需改这里) ====================
CHECK_INTERVAL=30 # 每隔多少秒检查一次
CHECK_CMD="pgrep -f -c 'ssh -fCN tunnel-to-aliyun'" # 检查命令轮程存在应返㮞0
EXEC_CMD="ssh -fCN tunnel-to-aliyun" # 轮程消失后执行的命令
# ===============================================================
while true; do
if ! eval "$CHECK_CMD" >/dev/null 2>&1; then
echo "[$(date '+%H:%M:%S')] Process not found, executing: $EXEC_CMD"
eval "$EXEC_CMD"
sleep 60*5
fi
sleep "$CHECK_INTERVAL"
done
# nohup ./check_tunnel_v3.sh > check_tunnel_v3.log 2>&1 &