Score:0

systemd - only run service after internet is up

us flag
[Unit]
Description=Twitter notifier daemon
# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/#cutthecraphowdoimakenetwork.targetworkforme
After=network-online.target systemd-networkd-wait-online.service
Requires=network-online.target systemd-networkd-wait-online.service

[Service]
ExecStart=/opt/twitter_streams/venv/bin/python -m twitter.notifier
KillSignal=SIGINT
Restart=on-failure
RestartSec=10s
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemd + ubuntu server 20.04 LTS

I wrote a python script - a twitter client that forwards messages from twitter to slack.

The problem is that whenever the system is rebooted, my script fails to run properly because it tries to connect to the twitter API before the internet is available. It does work fine if I enable it or restart it, just doesn't work on system startup or reboot.

I tried to require (alone & together):

network-online.target
systemd-networkd-wait-online.service

Any ideas?

bac0n avatar
cn flag
is the interface(s) [managed](https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html) by systemd-networkd?
v1z3 avatar
us flag
yes, I checked it's using systemd-networkd and not NetworkManager (the latter is not installed on ubuntu server at all)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.