I'm attempting to make a systemd service that should only start if a certain file doesn't exist on the file system.

If I use ConditionPathExists this will make the service start only when the file in question exists, which is the opposite behavior of what I want.

Is there a way to invert these conditions?


Yes, use ! to negate the condition:


It's in the manual:

With ConditionPathExists= a file existence condition is checked before a unit is started. If the specified absolute path name does not exist, the condition will fail. If the absolute path name passed to ConditionPathExists= is prefixed with an exclamation mark ("!"), the test is negated, and the unit is only started if the path does not exist.

  • Yup, definitely there, looks like I just glazed over it. – Mitch Dec 10 '18 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.