Bash脚本可以在一段时间内运行,但要等到一段时间后才能运行吗?

这很简单。我将其作为systemctl运行。

#!/bin/bash


until ping -c1 $1 www.google.com &>/dev/null
        do protonvpn c -f
done

我的systemctl是:

### BEGIN INIT INFO
# Provides:          protonvpn
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: autostartvpn
### END INIT INFO

[Unit]
After=remote-fs.target

[Service]
ExecStart=/dir/startupscript

[Install]
WantedBy=default.target

当我作为systemctl执行它时,它不起作用(上部脚本),并且由于未知原因,它在重新启动后通常停止工作。

I want to run this command protonvpn c -f on boot as soon as i get internet connection and i want it to loop until a connection is found (then kill-switch controls the app, and all works indefinitely).

你能帮我使它工作吗?

评论