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/[email protected]/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?

2
  • When you analyse the main pid (504) in the example, is the parent process showing as 1? Oct 6, 2017 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, 2017 at 20:42

1 Answer 1

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

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

You must log in to answer this question.

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