Can I group a set of related systemd service files into a common directory under `/etc/systemd/system`?

The usual directory to place systemd unit files is

/etc/systemd/system/

It contains a number of service files by default.

If I have a number of related service files which are all part of the same application system, can I create a subdirectory at this location to group them into a single folder?

For example, if I have three processes managed by systemd:

process1.service
process2.service
process3.service

is there a way to use those service files if I put them inside a directory

/etc/systemd/system/group_of_processes/

If I run systemctl daemon-reload the service files don’t appear to be picked up if they are under a subdirectory group_of_processes.

Asked By: user3728501

||

The answer to your question is that you cannot put a group of services into a subdirectory like that. Systemd looks for unit files in particular places, and that does not include subdirectories of /etc/systemd/system.

The places where systemd looks are unit files are documented in the system.unit man page.

You can do a bunch of things with dependencies that permit you to manage your services as a group (e.g, bring them all up/down together, or enable/disable them as a group), but you need to maintain the filesystem layout required by systemd.

Answered By: larsks
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.