13

I have this ~/.config/systemd/user/weechat.service systemd service which worked fine but after system upgrade the process gets killed which it didn't do before. The process is killed immediately when disconnected from SSH session.

[Unit]
Description=Weechat IRC Client (in tmux)
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/tmux -2 -u new-session -d -s irc /usr/bin/weechat
ExecStop=/usr/bin/tmux kill-session -t irc

[Install]
WantedBy=default.target

Status:

% systemctl --user status weechat.service
● weechat.service - Weechat IRC Client (in tmux)
   Loaded: loaded (/home/<user>/.config/systemd/user/weechat.service; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2017-10-05 22:54:54 EEST; 18h ago
  Process: 504 ExecStart=/usr/bin/tmux -2 -u new-session -d -s irc /usr/bin/weechat (code=exited, status=0/SUCCESS)
 Main PID: 504 (code=exited, status=0/SUCCESS)
   CGroup: /user.slice/user-1000.slice/user@1000.service/weechat.service
           ├─506 /usr/bin/tmux -2 -u new-session -d -s irc /usr/bin/weechat
           └─507 /usr/bin/weechat

/etc/systemd/logind.conf:

[Login]
KillUserProcesses=no

I've booted the system and also tried restarting systemd-logind.service.

Which config file / process / daemon is issuing the kill after logout?

raspi
  • 1,376

1 Answers1

16

You need to tell systemd to 'linger' your user:

# loginctl enable-linger <user>

This will cause your user services to be started on boot, and for logind to keep them around after you logout (e.g. close your ssh session).