小编Vla*_*r P的帖子

Bash:while 循环中的计时器

我的脚本中有一个 while 循环,它等待连接上线然后继续。

#!/bin/sh

while ! ping -c1 $1 &>/dev/null
        do echo "Ping Fail - `date`"
done
echo "Host Found - `date`"
Run Code Online (Sandbox Code Playgroud)

重新连接需要 25 到 45 秒。我不能让它等待超过 50 秒。限制循环工作时间的最佳解决方案是什么?

command-line scripting bash shell-script

3
推荐指数
2
解决办法
6746
查看次数

标签 统计

bash ×1

command-line ×1

scripting ×1

shell-script ×1