1

I have a service file named refreshPacman.service which runs pacman -Sy once on boot. However since After=network-online.target only accounts for my connection to the router (and not my VPN) pacman will fail to connect to the mirrors. I tried solving this originally by using a refreshPacman.timer that would simply wait 60 seconds after network-online.target, but this would lead to pacman either refreshing once my laptop's already way past logging in (too slow for my liking), or fail if I for some reason forgot how to type.

I was trying to create a better solution by modifying my previous service file, which would have systemd try to load the service some amount of times before either succeding or giving up. After failing to get my service to work I currently have this:

[Unit]
Description=refreshes pacman's database
Wants=network-online.target
Wants=mullvad-daemon.service
After=network-online.target
After=mullvad-daemon.service

StartLimitIntervalSec=180s
StartLimitBurst=3

[Service]
Type=oneshot
ExecStart=/usr/bin/pacman -Sy
RemainAfterExit=true

StandardOutput=journal

Restart=on-failure
RestartSec=60s

[Install]
WantedBy=multi-user.target

To my understanding, this should:

1. run the `ExecStart` once, (fail)
2. wait `RestartSec` seconds, (maby fail?)
3. repeat step 2 `StartLimitBurst` number of times

However according to both journalctl -u refreshPacman.service -b and /var/log/pacman.log the refresh command is only ever run once before giving up. I have made sure to disable & re-enable the service after updating it's contents (in case systemd doesn't like me editing the file the symling points to) but I can't get it to ever work. I still have a very limited understanding of how systemd works in general, so I'm not sure if I'm misunderstanding how on-failure or restarting works in general.

edit

I was messing around with a different service file, for some reason updating the timings to:

# nothing changed here

StartLimitIntervalSec=120s
StartLimitBurst=12

# nothing changed here

RestartSec=10s

allowed the service to work properly. I guess I was using such bloated timers for my testing that by the time I opened up the log file it still hadn't reloaded...

edit 2

I can't select my answer so IDK how to close this issue.

2
  • 1
    perhaps you need to systemctl daemon-reload Commented May 23, 2023 at 1:57
  • I tried it & still get the same issue.
    – Le-Kat
    Commented May 23, 2023 at 2:37

1 Answer 1

0

systemd was (probably) waiting too long to restart the task (answering so I can close the issue)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .