0

I'm using loginctl --enable-linger USERNAME to activate user services. The unit files are stored in $HOME/.config/systemd/....

Now a service that worked before starts (I can see it in process listing) and after some seconds it ends. I want to know, why it is stopped. I assume it crashes and gives some error output. Where can I see this error output or some logging of this systemd user unit?

1 Answer 1

3

The --user flag is needed to talk to the user's instance of systemd rather than the system instance.

Use systemctl --user status myunit.service to see a summary of the unit's status (along with the last few lines of the journal for that service) or journalctl --user -u myunit.service to read the full journal for that unit.

4
  • This has to be run in the users context right? I found another solution: loginctl user-status USERNAME
    – Michael
    May 25, 2023 at 6:58
  • Just tried you solution but it didn't work: $ systemctl --user status Failed to connect to bus: No such file or directory
    – Michael
    May 25, 2023 at 11:10
  • Hm, interesting. For what it's worth, the --user switch only works if you're logged in as the user you're asking about. On my Ubuntu 22.04 machine with systemd 249, the user socket is stored in /run/user/1000/bus (where 1000 is my UID). Do you have anything there?
    – smammy
    May 26, 2023 at 12:44
  • If you need to check it while logged in as a different user, run machinectl shell other-user@ and then systemctl --user ... inside it. su other-user doesn't give you the right environment.
    – sourcejedi
    May 27, 2023 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .