[systemd-devel] Service not restarting after Condition failed

Lennart Poettering lennart at poettering.net
Mon Nov 10 14:09:25 PST 2014


On Thu, 30.10.14 18:47, D.S. Ljungmark (spider at aanstoot.se) wrote:

> Hi
>  we have a service set to:
> ConditionFileNotEmpty=
> 
> and
> 
> Restart=Always
> 
> 
> This combination would (in my feebled mind) cause the service to restart
> once the Condition was fulfilled, but that doesn't seem to be the
> case.

Conditions are something that are on-time evaluated right before we
would start a unit, and cause this starting to be shortcut. That's all
really. Restarts are only triggered when a running service dies, and
the start job queued by that will then check the conditions again. If
the condition doesn't hold then this start will not be executed, and
hence no restart ever again either...

> Is there a way I can get a service to restart even after it has been set
> as inactive (dead) "start condition failed"?

Nope, conditions are not for that. For the specific check of
file-not-empty there's no nice way to handle this, however for
directory-not-empty you could set up DirectoryNotEmpty=...

> Should I simply remove the Condition, or something else?

What precisely are you trying to do?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list