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

14,612

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

Share:
14,612
Thao Nguyen
Author by

Thao Nguyen

I'm developer

Updated on June 25, 2022

Comments

  • Thao Nguyen
    Thao Nguyen almost 2 years

    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?