Jun 06, 2023
Run systemd user unit at boot time
User units install into the default.target target. The multi-user-wants.target does not exist in the user bus in systemd.
This means that “user” systemd units start only when that user spawns a user manager process.
By default a user manager process is only spawned at login and terminated afterwards. As a result, user systemd units that are enabled are only loaded once the user logs in.
Lingering
To change this, you can enable Lingering for the user. With lingering enabled, systemd (or rather, logind) will spawn a user manager process for that user at boot time and persist it between sessions, meaning systemd units loaded by that user will load even without the user logging in.
To enable linger for a user:
$ loginctl [dis|en]able-linger <uid or username>
Some examples:
1 | $ loginctl enable-linger chris |
Overall this process is controlled by logind’s KillUserProcesses configuration value.