Systemd tip: service conditionals

Adam Williamson awilliam at
Thu May 16 18:41:06 UTC 2013

In relation to the 'when startup delays become bugs' thread, it occurs
to me that perhaps not all packagers / devs know about one of the neater
systemd capabilities: conditional service activation. You can make
activation of your service conditional on a wide range of things,

1. The existence of a path or file
2. The fact that a file or directory actually contains something
3. The fact that a file is executable
4. The presence of a given parameter (or value of a parameter) on the
kernel cmdline
5. Whether the system is a VM (and what virtualization software it's
6. Whether the system is on AC power
7. Whether or not SELinux is enabled
8. Whether a given capability exists

It's really neat stuff, and very easy to use: you just add a
Condition(Something) statement to the .service file. For details on
using these conditions, see 'man systemd.unit' and just search for
Condition, and you'll find a list of all the available Conditions and
how to use them.
Adam Williamson
Fedora QA Community Monkey
IRC: adamw | Twitter: AdamW_Fedora | adamwfedora

More information about the devel mailing list