Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reattach to tmux process

Tags:

tmux

I had to reboot my box today. I had several program running in tmux sessions. They seem to be still alive, how can I reattach to them? I tried tmux a processID but it didn't work.

/home/me 21$ ps aux | grep tmux me    1299  0.0  0.0  22244  1920 ?        Ss   Apr28   0:40 tmux -2 -f /tmp/r-plugin-me/tmux.conf new-session -s vimrpluginme1398670569alnn51oynp1vollnn51f2v4r_ied_delta1meRalphaCalibr VIMINSTANCEID=alnn51oynp1vollnn51f2v4r_ied_delta1meRal me    2575  0.0  0.0  54164  3500 ?        S    07:35   0:00 xterm -e tmux -2 -f /home/me/.tmux.conf -S /tmp/vX0qRrR/78 me    2577  0.0  0.0  19892  1400 pts/2    Ss+  07:35   0:00 tmux -2 -f /home/me/.tmux.conf -S /tmp/vX0qRrR/78 me    2579  0.0  0.0  22128  1832 ?        Ss   07:35   0:00 tmux -2 -f /home/me/.tmux.conf -S /tmp/vX0qRrR/78 me    5155  0.0  0.0   6380   756 pts/4    S+   07:46   0:00 grep tmux me   31340  0.0  0.0  23348  3000 ?        Ss   Apr28   0:17 tmux -2 -f /home/me/.tmux.conf -S /tmp/vIqEM06/78 
like image 893
statquant Avatar asked May 01 '14 06:05

statquant


People also ask

How do I reattach to a tmux session?

When you detached from tmux and want to reattach to it again you use the tmux attach command. Without any argument this command reattaches tmux session that was the latest one to be detached. attach is a shorthand actually for attach-session , but both do the same thing so you can use them interchangeably.

How do I detach and attach tmux?

Detach From A Session To detach (meaning exit the window to come back to later) from the tmux session, use CTRL + b then d (hold ctrl, press b, let go of both of the keys, and press d). Whatever program(s) you are running in the tmux session will continue going without you.

How use tmux attach in Linux?

First, you press Ctrl+B to get tmux 's attention. You then quickly press the next key to send a command to tmux . Commands are given by pressing letters, numbers, punctuation marks, or arrow keys. It's the same in screen , except you press Ctrl+A to get its attention.


2 Answers

You can not re-attach a process id. You need to reattach the corresponding tmux session.

So do tmux ls. Pick whatever session you want to re-attach. Then do tmux attach -d -t <session id> to re-attach it to a new tmux instance and release it from the old one.

like image 170
oakad Avatar answered Nov 04 '22 10:11

oakad


If you only have one session detached you can just do

tmux attach 

also if you're going to be working in multiple sessions it might be a good idea to name your sessions

tmux new -s ssh-to-staging Ctrl b, d   # Detach from session tmux new -s ssh-to-s3 Ctrl b, d   Detach from session  

now when you do tmux ls you can reattach more easily without guessing.

tmux attach -d -t ssh-to-s3 

You also might wanna bookmark this cheat sheet

like image 32
lacostenycoder Avatar answered Nov 04 '22 11:11

lacostenycoder