autoDeploy/pingdomain.sh
zhangkun9038@dingtalk.com e93dfa80a8 ping baidu
2025-03-30 20:57:03 +08:00

20 lines
396 B
Bash
Executable File
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
# 尝试ping baidu.com共30次
for i in {1..30}; do
ping -c 1 baidu.com >/dev/null 2>&1
# 检查上一个命令的退出状态
if [ $? -eq 0 ]; then
# 如果ping成功则退出脚本
echo "Ping successful, no action needed."
exit 0
fi
# 等待10秒后再次尝试
sleep 10
done
# 如果所有ping尝试都失败则执行ssh命令重启
ssh mi reboot