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?
The program systemd is the process with process ID 1. It is responsible for initializing the system in the required way. systemd is started directly by the kernel and resists signal 9, which normally terminates processes. All other programs are either started directly by systemd or by one of its child processes.
Unit files are stored in the /usr/lib/systemd directory and its subdirectories, while the /etc/systemd/ directory and its subdirectories contain symbolic links to the unit files necessary to the local configuration of this host.
A unit file is a plain text ini-style file that encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start-up target, a watched file system path, a timer controlled and supervised by systemd(1), a resource management slice or a group of externally ...
Unit files found in this directory have a priority landing between those in /etc/systemd/system and /lib/systemd/system . Files in this location are given less weight than the former location, but more weight than the latter.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With