[systemd-devel] problem with service that uses bash loop

Michał Piotrowski mkkp4x4 at gmail.com
Tue Mar 29 13:07:34 PDT 2011


W dniu 29 marca 2011 21:52 użytkownik Lennart Poettering
<lennart at poettering.net> napisał:
> On Tue, 29.03.11 21:46, Michał Piotrowski (mkkp4x4 at gmail.com) wrote:
>
>> > Ah of course! Otherwise the modprobe is executed right when the last
>> > process you ran before exited...
>>
>> I do not understand why this is so.
>>
>> example I
>> Type=oneshot
>> ExecStart=A
>> ExecStart=B
>> ExecStop=C
>>
>> example II
>> Type=oneshot
>> RemainAfterExit=yes
>> ExecStart=A
>> ExecStart=B
>> ExecStop=C
>>
>> what is the difference in the sequence of execution in these example scripts?
>>
>> I think in both cases is:
>> start:
>> - A
>> - B
>> stop:
>> - C
>
> Completely correct. However, if you have RemainAfterExit=no then systemd
> will notice that no process is running anymore, right after it was
> started and hence call the stop binaries right-away.
>
> If you use RemainAfterExit=yes however systemd doesn't care if there is
> no process around for that service, and just considers it up until the
> user (or the system shutdown logic) pulls it down explicitly.
>
> In different words:
>
> RemainAfterExit=no means: as soon as no process is around anymore a
> service is considered down, and the stop binaries are executed.

This explains everything. Thanks!

> The
> service will go into "deactivating" right after it was done with
> "activating".
>
> RemainAfterExit=yes means: the stop binaries are only executed when the
> user manually stops the service, or if if this done due to system
> shutdown. The service will stay in "activated" after having left
> "activating" until the user manually changes it to "deactivating" via
> "systemctl stop".
>
> Lennart
>
> --
> Lennart Poettering - Red Hat, Inc.
>



-- 
Best regards,
Michal

http://eventhorizon.pl/


More information about the systemd-devel mailing list