Timeline for How to make a systemd-timer depend on internet connectivity?
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Feb 7, 2023 at 6:53 | history | suggested | MrMeszaros | CC BY-SA 4.0 |
Add scope limitations and a possible fix
|
| Feb 2, 2023 at 23:10 | review | Suggested edits | |||
| S Feb 7, 2023 at 6:53 | |||||
| Sep 19, 2021 at 10:52 | comment | added | FelixJN | No worries. - Yes, system level and user level are fully independent - see here or here. I'd suggest you make a small ping test service to some reliable internet address. | |
| Sep 17, 2021 at 14:57 | comment | added | Zeta.Investigator |
Sorry for bothering again...actually my timer/service are defined in .config/systemd/user (user-level)...so I can't depend on network-online.target which is a system service, right? I need to write my own connection-detector service at user-level right?
|
|
| Sep 16, 2021 at 15:53 | comment | added | FelixJN |
@Zeta.Investigator That is an emergeny stop only. Check the PartOf= directive for a start-and-stop dependency. More details here
|
|
| Sep 16, 2021 at 15:20 | comment | added | Zeta.Investigator |
BindsTo= option is only relevant in boot process? I mean, can I use it to disable the timer when network suddenly turns off and re-enable it when it becomes available? (After boot). I used BindsTo= and After= with network-online.target but when network came back online, the timer didn't reactivate
|
|
| Sep 16, 2021 at 11:38 | vote | accept | Zeta.Investigator | ||
| Sep 16, 2021 at 11:37 | comment | added | FelixJN |
Simple: If you do not define to start the timer after online target, the countdown will start earlier (e.g. when you defined it as WantedBy=multi-user.target in the [Install] section it will start at boot time - independently of the network status). If you define it in the service file, it will wait for the online target after triggering the service via the timer.
|
|
| Sep 16, 2021 at 11:29 | comment | added | Zeta.Investigator |
and what would be the difference if I add After=network-online.target to the Unit section of corresponding .service file (not .timer)?
|
|
| Sep 16, 2021 at 11:27 | comment | added | FelixJN |
Wants will also make the timer try to start the network target. You may add it, but I think for your case it is not that necessary - since I assume you always start the network by default. If your connection is unstable, you may rather think of something like BindsTo=, i.e. stopping the timer if the network connection breaks. More details on the relative dependency options here: Service unit configuration
|
|
| Sep 16, 2021 at 11:17 | comment | added | Zeta.Investigator |
Thanks, do I also need to add Wants=network-online.target?
|
|
| Sep 16, 2021 at 10:36 | history | edited | FelixJN | CC BY-SA 4.0 |
added 475 characters in body
|
| Sep 16, 2021 at 10:26 | history | edited | FelixJN | CC BY-SA 4.0 |
added 319 characters in body
|
| Sep 16, 2021 at 10:25 | history | edited | Stephen Kitt | CC BY-SA 4.0 |
Typo.
|
| Sep 16, 2021 at 10:24 | history | answered | FelixJN | CC BY-SA 4.0 |