I tried tmux on Ubuntu Server 22.04, and closing SSH terminal did not terminate tmux. I did the same thing on Gnome Manjaro, tmux was terminated. Can I make it keep running, like Ubuntu?
There was the same question ( Tmux dies when logging out from remote ) but it is old so the thread was closed, and the reply "
ssh.service instead of
ssh.socket" does not seem to work, because when I executed
systemctl, I saw “sshd.service”, not “ssh.socket”.
/etc/systemd/system/multi-user.target.wants/sshd.service already had
KillMode=process. I want to avoid that complicated
systemd-run --scope --user... thing if possible. It did not require that on Ubuntu, so shouldn’t it be possible on Manjaro, too?
You need to enable lingering.
I enabled it (
loginctl user-status says
Linger: yes), but still closing the terminal seems to close tmux, because if I relog in and type
tmux ls, it says
no server running on /tmp/tmux-1000/default. I have not rebooted the PC. Is a reboot required?
You’re in a unique position to check and report back…
Well, rebooting did not make it work either.
How are you exiting tmux?
I have tried both: ctrl+b, :, detach, and just closing the SSH window. They had the same result.
I’m pretty sure you’ll be able to find what you’re looking for here:
And here: systemd/User - ArchWiki
It seems that on Arch-based (I don’t know if Manjaro has the same configuration but I guess so) systems, you don’t need linger because systemd is configured to not kill user processes after logout.
It’s unclear from your first post what your server is running (Manjaro or Ubuntu).
Which part exactly am I suppose to read. The only part that I think may be related is the service part. Do I have to run tmux as a service to keep it running after SSH is disclosed?
You mean disconnected, right? And
But it makes sense, since a service doesn’t exit…normally…
And to which server are you connecting to? And on which machine are you running tmux?
Yeah, disconnected from the SSH connection.
But with Ubuntu server, when I re-logged in SSH, the session was still there. I did not do any special configuration other than just running
sudo apt install tmux.
The server is Manjaro. The client was Windows Terminal, but probably Windows Terminal (on Windows 11) is not the cause, because I used the same app to connect to both Manjaro and Ubuntu.
Your client should not matter at all because you’re running tmux on the server.
It should work right away with the default settings. Are you using the default settings?
No, I did not change any tmux settings. So, enabling lingering is not needed, right? I have a Manjaro Gnome virtual machine that I had set up to ask about the Docker bridge network problem (which I still have not found a solution and gave up). I had created a snapshot after doing nothing but installing updates after the installation.
So, in the VM, I only installed tmux. I locally (by locally, I mean within the VM’s Gnome desktop) created a session, detached it, and logged out of Gnome desktop, re-logged in to the desktop, and
tmux ls showed the session.
I reverted the VM to the previous state, installed openssh, and connected to it over SSH, installed tmux, created a session, detached it, disconnected from the SSH by typing
exit, re-logged into the SSH, and
tmux ls showed
no server running on /tmp/tmux-1000/default.
Please try it over SSH with your Manjaro.
Test on rpi running manjaro-arm minimal
Install tmux and mc
sudo pacman -Syu tmux mc
Start a tmux session named mc
tmux new -s mc
Start the filemanager
Close the terminal window and open a new window
Then attach to the session
tmux attach -d -t mc
If you didn’t name your session - you still have a numbered list
Then switch to a session by number e.g.
tmux -d -t 0
I can’t anything of value to aarhus’ post above. I tested it with a new VM and it works right away exactly as it’s supposed to (xfce minimal as opposed to arm-minimal).
It seems it has something to do with Gnome. Because with XFCE I also had no problems, but Gnome with GDM did not worked. The tmux process was killed, even with
logind.conf (which is the default).
The only thing that worked was to start tmux with
systemd-run and linger was enabled.
systemd-run --scope --user tmux
The systemd services from the Arch Wiki page might also work, but I did not tried these.
But this is a good example why using a GUI on a server is stupid.