You are not logged in.
Hey guys,
So I have been banging my head against the wall for a while with this issue. I'm trying to have a systemd service that runs reflector on boot in order to update my pacman mirrorlist. However, the service always seems to run before a network connection exists. Here's reflector.service:
[Unit]
Description=Pacman mirrorlist update
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/reflector --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist
[Install]
RequiredBy=multi-user.target
The network-online target, to my knowledge, is triggered only by a netctl-auto hook, which looks as such:
#!/bin/sh
ExecUpPost="systemctl start network-online.target"
ExecDownPre="systemctl stop network-online.target"
When I start the system and login, reflector.service is already marked as failed, despite the fact that netctl-auto has not yet established a connection. Why isn't it waiting to run? Am I missing something here?
Last edited by brandonio21 (2016-07-03 23:27:05)
Offline
With Wants= After= you have an optional dependency only.
Use Requires= After= instead to get a hard dependency:
see https://wiki.archlinux.org/index.php/Sy … pendencies
Offline
You're right. I've changed the unit file to contain Requires, but alas, still not cigar.
It's quite perplexing because upon booting into the system, before the network is even connected, reflector.service is marked as failed. This leads me to believe that network-online.target is being started much before it should; however, I can find no evidence of this anywhere.
Offline
The systemd journal should tell the starting sequence of the units.
Can you post it, beginning at the start of the systemd-journald service (the previous kernel lines are useless here).
Offline
Thanks for all your help, berbae. After looking into the logs you suggested, I found that there was indeed something else starting network-online.target
In order to remedy my reflector situation, I made a new target, network-connected.target, and used netctl-auto's ExecUpPost to start it. However, this resulted in the same issue.
After struggling for quite some time, I've resolved to simply use a systemd timer to start all services that require an Internet connection and start them 1 minute after boot (While also forcing them to be "After" network-online.target).
Offline
This sounds a bit like a silly question, but it appears, according to the article on netctl hooks, that the auto-hook you listed isn't there by default and you have to add it. That's what it seemed like from the article.
Offline