I am trying to:
- run a bash script on booting Kubuntu (Ubuntu 19.10)
- after my internet connection is established
- using systemd (using the network-online.target service)
I wrote the .service file below. It refers to an sh executable that tests if IPv4 is up via ping.
- The script (which is executable by all) works, it tells me I'm up when I run it manually.
- Systemd calls the script successfully on boot, I can see the script has run after booting
However, somehow systemd calls my service before my internet connection is up while it should wait for the internet connection before running. Anybody any idea what is going wrong here? See code below:
My script (/home/me/scripts/testInternetConnection.sh):
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then echo "IPv4 is up" >> /home/me/Desktop/result.txt
else echo "IPv4 is down" >> /home/me/Desktop/result.txt
fiMy service file definition (/etc/systemd/system/myConnectionTester.service):
[Unit]
Description=test internet connection
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=me
WorkingDirectory=/home/me
ExecStart=/home/me/scripts/testInternetConnection.sh
[Install]
WantedBy=multi-user.target
WantedBy=network-online.serviceThanks in advance!
N.
5 Reset to default