Post History
Yup that's the recommended way to do it. Wants adds the network-online.target as a soft dependency.[1] Systemd will try to start it if it isn't up already. Networking should work after this target...
Answer
#2: Post edited
- Yup that's the recommended way to do it.
[`Wants`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Wants=) adds the [`network-online.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#network-online.target) as *a soft* dependency.[^hard-dependency] Systemd will try to start it if it isn't up already. Networking should be up after this target.- [`After`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Before=) specifies the ordering related to other units. Without this they would likely be started concurrently.
- You almost always want the two directives. One for the dependency and one for their ordering. Here's an exception though:
- DNS lookups work after [`nss-lookup.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#nss-lookup.target) so you probably don't want your unit to be scheduled before this. The docs tell us not to add it to `Wants`. This way systemd won't start it when your unit is started, but should they happen to be in the same transaction – say, during the boot – then the ordering is respected.
- [^hard-dependency]: You could consider a hard dependency with [`Requires`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Requires=), but soft dependencies are recommended for a more robust boot.
- Yup that's the recommended way to do it.
- [`Wants`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Wants=) adds the [`network-online.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#network-online.target) as *a soft* dependency.[^hard-dependency] Systemd will try to start it if it isn't up already. Networking should work after this target.
- [`After`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Before=) specifies the ordering related to other units. Without this they would likely be started concurrently.
- You almost always want the two directives. One for the dependency and one for their ordering. Here's an exception though:
- DNS lookups work after [`nss-lookup.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#nss-lookup.target) so you probably don't want your unit to be scheduled before this. The docs tell us not to add it to `Wants`. This way systemd won't start it when your unit is started, but should they happen to be in the same transaction – say, during the boot – then the ordering is respected.
- [^hard-dependency]: You could consider a hard dependency with [`Requires`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Requires=), but soft dependencies are recommended for a more robust boot.
#1: Initial revision
Yup that's the recommended way to do it. [`Wants`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Wants=) adds the [`network-online.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#network-online.target) as *a soft* dependency.[^hard-dependency] Systemd will try to start it if it isn't up already. Networking should be up after this target. [`After`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Before=) specifies the ordering related to other units. Without this they would likely be started concurrently. You almost always want the two directives. One for the dependency and one for their ordering. Here's an exception though: DNS lookups work after [`nss-lookup.target`](https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#nss-lookup.target) so you probably don't want your unit to be scheduled before this. The docs tell us not to add it to `Wants`. This way systemd won't start it when your unit is started, but should they happen to be in the same transaction – say, during the boot – then the ordering is respected. [^hard-dependency]: You could consider a hard dependency with [`Requires`](https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Requires=), but soft dependencies are recommended for a more robust boot.