我怎样才能重新连接到tmux进程

sta*_*ant 36 tmux

我今天不得不重启我的盒子.我有几个程序在tmux会话中运行.他们似乎仍然活着,我怎么能重新加入他们?我试过tmux a processID但它没用.

/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
Run Code Online (Sandbox Code Playgroud)

oak*_*kad 46

您无法重新附加进程ID.您需要重新连接相应的tmux会话.

那样做tmux ls.选择您要重新附加的任何会话.然后tmux attach -d -t <session id>重新将它附加到新的tmux实例并从旧实例中释放它.

  • 如果您只有一个已脱离的会话,那么也可以使用“tmux Attach”。 (24认同)
  • `tmux a -t &lt;session id&gt;` 似乎也对我有用。 (6认同)

lac*_*der 8

如果你只有一个会话分离,你可以做

tmux attach
Run Code Online (Sandbox Code Playgroud)

此外,如果您要在多个会话中工作,那么命名您的会话可能是个好主意

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

Run Code Online (Sandbox Code Playgroud)

现在,当您这样做时,您tmux ls无需猜测就可以更轻松地重新连接。

tmux attach -d -t ssh-to-s3

You also might wanna [bookmark this cheat sheet][1]


  [1]: https://duckduckgo.com/?q=tmux%20cheat%20sheet&atb=v86-5__&ia=cheatsheet&iax=cheatsheet&iai=r1-9&page=1&sexp=%7B%22cdrexp%22%3A%22b%22%2C%22artexp%22%3A%22b%22%2C%22prodexp%22%3A%22b%22%2C%22prdsdexp%22%3A%22c%22%2C%22biaexp%22%3A%22b%22%2C%22msvrtexp%22%3A%22b%22%7D
Run Code Online (Sandbox Code Playgroud)