I'm ruing a set of Debian Jessie based servers and need a reliable way to upload their local network IP Address when the network link is established. I wrote a script that does this and registered it as a systemd service:
[Unit]
Description=Server Registration
Requires=network.target network-online.target
After=network.target network-online.target
[Service]
ExecStart=<script-location>
Type=simple
Restart=on-failure
WatchdogSec=21600
[Install]
WantedBy=multi-user.target
Alas, if this were working as expected it wouldn't be a question on SO. The script makes use of the route command to determine the network device used by default, but fails to run because route exits due to the network not being up yet. Also, the system may boot up without a network coection and only be coected later, so the script needs to be triggered anytime the network goes up.
Network is set up using systemd-networkd.
How can i ensure that my script is run whenever the network goes up, and not before?
برچسب:
نویسنده: استخدام کار