啟動 ping-endpoint.timer
:
[Unit]
Description=Timer to ping endpoint every 10s after network is up
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-eth0.device
[Timer]
OnActiveSec=0
OnUnitActiveSec=10s
Unit=ping-endpoint.service
[Install]
WantedBy=timers.target
啟動 ping-endpoint.service
:
[Unit]
Description=Ping specified endpoint
After=network.target network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/ping -c 1 [ENDPOINT IP]
SuccessExitStatus=0 1 2
sudo systemctl daemon-reload
sudo systemctl enable --now ping-endpoint.timer