4

I have had a tmux session running for a while, and I can see it's running using pstree:

systemd─┬─accounts-daemon───2*[{accounts-daemon}]
        ├─2*[agetty]
        ├─containerd───11*[{containerd}]
        ├─cron
        ├─dbus-daemon
        ├─4*[dd]
        ├─dockerd───12*[{dockerd}]
        ├─fail2ban-server───2*[{fail2ban-server}]
        ├─irqbalance───{irqbalance}
        ├─networkd-dispat
        ├─polkitd───2*[{polkitd}]
        ├─qemu-ga
        ├─rsyslogd───3*[{rsyslogd}]
        ├─ssh-agent
        ├─sshd───sshd───sshd───bash───pstree
        ├─systemd───(sd-pam)
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-network
        ├─systemd-resolve
        ├─systemd-timesyn───{systemd-timesyn}
        ├─systemd-udevd
        ├─tmux: server─┬─bash───find_cli
        │              └─3*[bash]
        └─unattended-upgr───{unattended-upgr}

(it's down the bottom there)

However, tmux itself insists there are no sessions:

$ tmux attach
no sessions
$ tmux ls
no server running on /tmp/tmux-1000/default

Is there any way to recover a tmux session in this situation?

5
  • 1
    Is it actually running as the current user, or as some other user?
    – Kusalananda
    Apr 25, 2020 at 12:13
  • Or with a non-default socket. See man 1 tmux, options -L and -S. Can it be the case? On the other hand, if you started a server in a non-default way, you would probably know. Apr 25, 2020 at 12:31
  • Looks like that tmux is being run by another user on the system. See if any other user is logged into the system. use w
    – GMaster
    Apr 25, 2020 at 13:52
  • @GMaster They might have started tmux as root, disconnected from it, and forgotten about it.
    – Kusalananda
    Apr 25, 2020 at 18:00
  • Yes it must be running as me (ubuntu), because ps -aux returns ubuntu 23508 0.8 0.0 19116 7696 ? Ss Mar02 673:09 tmux
    – Migwell
    Apr 26, 2020 at 14:00

1 Answer 1

9

If the socket has been removed you should be able to make tmux recreate it with pkill -USR1 tmux.

7
  • 1
    I still have a process running under that tmux session which I can't afford to cancel. Will this affect the child process?
    – Migwell
    Apr 26, 2020 at 14:01
  • 1
    It shouldn't do. Apr 26, 2020 at 15:12
  • 1
    I don't know why this works, but it does. I was able to tmux attach immediately after running that command.
    – Migwell
    Apr 27, 2020 at 4:23
  • Something removed your tmux socket in /tmp and sending this signal to the tmux server asks it to create it again. Apr 27, 2020 at 5:46
  • 1
    I can confirm I had exactly the same issue and this solution worked without killing the running processes Jun 3, 2021 at 19:14

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.