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

        ├─tmux: server─┬─bash───find_cli
        │              └─3*[bash]

(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?

  • 1
    Is it actually running as the current user, or as some other user? – Kusalananda Apr 25 '20 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. – Kamil Maciorowski Apr 25 '20 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 '20 at 13:52
  • @GMaster They might have started tmux as root, disconnected from it, and forgotten about it. – Kusalananda Apr 25 '20 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 '20 at 14:00

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

  • 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 '20 at 14:01
  • It shouldn't do. – Nicholas Marriott Apr 26 '20 at 15:12
  • I don't know why this works, but it does. I was able to tmux attach immediately after running that command. – Migwell Apr 27 '20 at 4:23
  • Something removed your tmux socket in /tmp and sending this signal to the tmux server asks it to create it again. – Nicholas Marriott Apr 27 '20 at 5:46
  • Ah, so USR1 is a program-defined signal that tmux uses as a signal to recreate the socket. pkill here isn't being used to kill the process, but rather send USR1 to tmux. – Migwell Apr 27 '20 at 5:51

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.