5

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?

  • When you analyse the main pid (504) in the example, is the parent process showing as 1? – Raman Sailopal Oct 6 '17 at 15:02
  • @RamanSailopal PID 504 isn't running. Looking at pid 506 reports parent PID as 498. 498's parent PID is 1. – raspi Oct 6 '17 at 20:42
5

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).

  • 1
    To see whether lingering is enabled for your user, execute loginctl show-user $(whoami) --property Linger. – Ichimonji10 Nov 8 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.