Can you put systemd units under a custom path?
The systemd manual gives a list of path where systemd looks for unit files.
However, I want to isolate my units in a path of my own choosing. Is it possible to configure systemd to add some path to that list of search locations?
1 answer
There are a few ways to do this. From the documentation you linked:
When the variable
$SYSTEMD_UNIT_PATH
is set, the contents of this variable overrides the unit load path.
Option 1: Edit that environment variable to something like /home/me/custom-units:
. The trailing colon indicates the usual load paths should also be used, with a lower priority.
Moreover, additional units might be loaded into systemd from directories not on the unit load path by creating a symlink pointing to a unit file in the directories. You can use systemctl link for this...
Option 2: Use this command. An example invocation is systemctl link /home/me/custom-units/my-custom-unit.service
. This would link a single unit file into systemd so it can be started with systemctl start my-custom-unit
. If there are other units in the same directory, those will need to be linked as well. Links persist until systemctl disable
is run on them.
Unit files are loaded from a set of paths determined during compilation
Option 3: Compile your own systemd and change the paths in systemd.pc.in. Not for the faint of heart.
0 comment threads