What is the Difference between ConditionPathExists= and ConditionPathExists=| in systemd?

Thao Nguyen picture Thao Nguyen · May 19, 2016 · Viewed 10.7k times · Source

I need check a file not exist before i start my service in Systemd. I see two case in [Unit]:

ConditionPathExists=!/tmp/abc

and

ConditionPathExists=|!/tmp/abc

are they the same? Can anybody help me explain if they are different?

Answer

khrm picture khrm · May 19, 2016

Sometime you specify multiple files like:

ConditionPathExists=!/tmp/abc
ConditionPathExists=!/tmp/abe

Now if any of the condition isn't satisfied, it doesn't start service. It's like and operations.

Now if you use:

ConditionPathExists=|!/tmp/abc
ConditionPathExists=|!/tmp/abe

If any of these conditions is satisfied, it will run the service.

Condition checks can be prefixed with a pipe symbol (|) in which case a condition becomes a triggering condition. If at least one triggering condition is defined for a unit, then the unit will be executed if at least one of the triggering conditions apply and all of the non-triggering conditions

It's like OR operations