I'm working on setting up a Linux server that will have dozens of daemons controlled by systemd. The daemons are grouped into targets so that they can be brought up and down in groups, but the system administrators can manually control individual services. I am looking for a way to preserve the state (which services are activated) through a reboot. The idea is that people debugging, testing, and developing on the server can reboot it if needed and have the system come up in the same configuration as it was before the reboot.
systemd's snapshot
functionality seems ideal for this, but as far as I can tell you can't write a snapshot to disk for use later.
My initial plan was to create a symlink from multi-user.target.wants/
to a service called bootingup.service
. Every target the system administrator activates would then rewrite bootingup.service.d/bootingup.conf
to launch the target that was just activated. This would mean that on boot the system would activate the most recently launched target, but it wouldn't remember any services that were individually activated/deactivated.
Is there a way to make systemd remember the state of all services across a reboot?
enable
anddisable
are for.systemd
keeps track of all servicesenabled
by symlinks from/usr/lib/systemd/system/
to/etc/systemd/system/[target]
.enabled
means the service starts at boot,disabled
means it doesn't. Services can bestarted
/stopped
regardless of whether or not they areenabled
/disabled
.sudo systemctl enable --now TARGET.target
. The problem is that ifTARGET.target
is deactivated through aConflict=
tag in another unit it is not disabled.alias
systemctl start
to a script that will handle the disabling/enabling that you want.systemd
does not preservestart
/stop
commands, onlyenable
/disable
commands.Systemd
only respects the symlinks in the default target and all of their dependencies.