You are not logged in.

#1 2024-03-29 07:11:03

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

[Solved] tmux server being killed after logging out

expected:

I ssh to Arch server, login with non-root user, `tmux` to create a new session, `<prefix> d` to detach from it, exit ssh connection, ssh back, still be able to `tmux a` to attach to the pervious session.

in fact:

When I ssh to the server again, run `tmux a` gets `no sessions`, run `tmux ls` gets `no server running on /tmp/tmux-1000/default`.

I've checked https://wiki.archlinux.org/title/System … _on_logout, I didn't modify `KillUserProcesses` in `/etc/systemd/logind.conf` before.

If I run `systemd-run --scope --user tmux` to start tmux session, it remains after relogin.

And I did `sudo loginctl enable-linger`.

Last edited by freeeeezing (2024-03-29 16:23:32)

Offline

#2 2024-03-29 07:57:48

seth
Member
Registered: 2012-09-03
Posts: 59,829

Re: [Solved] tmux server being killed after logging out

If I run `systemd-run --scope --user tmux` to start tmux session, it remains after relogin.

Means it's only systemd killing the process.

What does /etc/systemd/logind.conf look like and have you tried the explciitly disable KillUserProcesses (and reboot to be extra-super-safe on this)
"loginctl list-users" shows lingering for your reelvant user being enabled?

For tmux specifically, see https://wiki.archlinux.org/title/Tmux#A … th_systemd

Offline

#3 2024-03-29 08:04:41

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

In /etc/systemd/logind.conf KillUserProcesses equals no with a '#' in the begining. (meaning I had never modified that I guess) And the default is "no" accroding to wiki.

loginctl list-users
UID USER  LINGER STATE
1000 sxing yes    active

1 users listed.

It's active

I don't want to config sshd specifically

Last edited by freeeeezing (2024-03-29 08:07:24)

Offline

#4 2024-03-29 08:06:30

seth
Member
Registered: 2012-09-03
Posts: 59,829

Re: [Solved] tmux server being killed after logging out

Yes, is - the idea however was to explicitly set it to "no" and not rely on any defaults here.

Offline

#5 2024-03-29 08:19:00

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

It's my logind.conf now

[Login]
#NAutoVTs=6
#ReserveVT=6
KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
...

I did as you say and rebooted.

Systemd still kills tmux server.

Last edited by freeeeezing (2024-03-29 08:37:46)

Offline

#6 2024-03-29 08:35:19

seth
Member
Registered: 2012-09-03
Posts: 59,829

Re: [Solved] tmux server being killed after logging out

Please use [code][/code] tags. Edit your post in this regard.
lingering affects user services *only*, but you're starting tmux as regular process, so you're not getting around running it either as a system service (for the user), or running it as user service (and enable lingering)
W/ all the issues and caveats that at least in the past have existed around lingering, I'd suggest to go for the system service (and disable lingering again)

Offline

#7 2024-03-29 15:40:48

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

Like I said I don't want to manually add a service for tmux.

What I expected should be the default behavior and I confirmed that by a newly install in a VM.

I will look for the reason why systemd kills tmux.

Offline

#8 2024-03-29 16:05:50

seth
Member
Registered: 2012-09-03
Posts: 59,829

Re: [Solved] tmux server being killed after logging out

Check
· /etc/systemd/logind.conf
· /etc/systemd/logind.conf.d/*.conf
· /run/systemd/logind.conf.d/*.conf
· /usr/lib/systemd/logind.conf.d/*.conf
for overrides, mind KillOnlyUsers

Offline

#9 2024-03-29 16:13:02

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

I add "KillExcludeUsers=root MY_USERNAME" to logind.conf and problem solved

Don't understand why this should be set again if the "global" one is set to no.

Offline

#10 2024-03-29 16:16:19

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

OMG I found optimus manager write to /usr/lib/systemd/logind.conf.d/*.conf which set KillUserProcess to yes

Offline

#11 2024-03-29 16:19:22

freeeeezing
Member
Registered: 2024-03-29
Posts: 22

Re: [Solved] tmux server being killed after logging out

These 4 locations have been written on the head of man logind.conf but I have never noticed them. I will keep that in my mind.

Thanks for your help, seth!

Offline

#12 2024-03-29 16:19:51

seth
Member
Registered: 2012-09-03
Posts: 59,829

Re: [Solved] tmux server being killed after logging out

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB