4

Given a service definition at ~/.config/systemd/user/do-something.service for UID 1000, which is installed, enabled, and starts automatically at login, I would like the do-something.service to start at system boot instead.

One possible solution would be to install [email protected] as a dependency of the system’s multi-user.target, but then the question becomes whether this is a recommended setup and what its downsides are.

Amir
  • 1,531
  • 1
  • 14
  • 18

1 Answers1

5

As I learned from the systemd/User entry on ArchWiki, starting the user manager at boot is handled by systemd-logind. For the current user:

loginctl enable-linger

And for a different USER (username or ID):

sudo loginctl enable-linger USER

From the man page:

If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services.

Amir
  • 1,531
  • 1
  • 14
  • 18