[systemd-devel] Question about changing systemd target during boot
Michael Chapman
mike at very.puzzling.org
Mon Aug 1 11:23:43 UTC 2016
On Mon, 1 Aug 2016, Andrei Borzenkov wrote:
[...]
>> So here goes what I've done:
>>
>> 1. Create a service and put it in the network-online.target:
>>
>> /etc/systemd/system/change-target.service:
>> [Unit]
>> Description=Change Target
>> Wants=network-online.target
>> After=network-online.target
>>
>> [Service]
>> Type=oneshot
>> ExecStart=/tmp/script.sh
>> TimeoutSec=60s
>>
>> [Install]
>> WantedBy=network-online.target
>>
>
> This unit have conflicting requirements - on one hand it is
> After=network-online.target, OTOH WantedBy=network-online.target
> implies Before=network-online.target.
I've seen this asserted on this list a few times, but as far as I can tell
it isn't actually correct. After/Before are meant to be completely
orthogonal to Wants/Requires/etc., according to the documentation.
If A.service has:
Wants=B.service
Before=B.service
then any time you ask A.service to be started, systemd will add a job to
start B.service... but it still ensures that A.service is started *before*
B.service.
Is my understanding on this incorrect? I have been making use of this
behaviour for quite some time, and as far as I can tell it has never
failed.
- Michael
More information about the systemd-devel
mailing list