[systemd-devel] systemctl start second.service first.service

Reindl Harald h.reindl at thelounge.net
Thu Jan 11 14:34:38 UTC 2018



Am 11.01.2018 um 15:25 schrieb Uoti Urpala:
> On Thu, 2018-01-11 at 10:59 +0000, 林自均 wrote:
>> I have 2 service unist: first.service and second.service. I
>> configured "After=first.service" in second.service. Both services are
>> "Type=oneshot".
>>
>> If I execute:
>>
>> # systemctl start first.service second.service
>>
>> The ordering dependency will work, i.e. second.service will start
>> after first.service.
>>
>> However, if I execute:
>>
>> # systemctl start second.service first.service
>>
>> first.service and second.service will start at the same time.
>>
>> Is this behavior documented somewhere? Thanks!
> 
> I'd guess this is due to systemctl starting each listed unit
> independently rather than as a single transaction. Thus, the second
> version first starts second.service without first.service being active
> at all. Since there's only an After relationship, not Wants/Requires,
> second.service will immediately start. Then systemctl starts
> first.service; since second.service is already running, there's nothing
> the After relationship could affect

but why?

the one "After=" should be enough to have a clear ordering of stop/start 
both as it happens in shutdown/boot


More information about the systemd-devel mailing list