如果我连接到互联网,我希望运行一个脚本。我的想法是将某个东西添加到crontab中,每隔5分钟运行一次,尝试ping一个web服务器,如果失败则运行一个命令,如果成功,则结束脚本。
伪代码:
```bash while True: response = ping(webserver) if response == "success": break else: run_command() sleep(300) ```
#!/bin/zsh
if ping IP is unsuccessful
echo test
end
if ping -c 1 myhost &>/dev/null; then
- Colin