Você deve iniciar os shells em screen ou tmux para que eles possam ser facilmente reconectados em um novo terminal.
Com screen , isso é feito com as seguintes etapas:
-
Inicie o shell em algum lugar (por exemplo, no VNC):
screen -S myshell -
Recoloque o shell em outro lugar (por exemplo, um novo terminal com SSH):
screen -x myshell
Embora os métodos acima sejam altamente recomendados, eles não são suficientes para controlar um shell existente . Para isso, você precisará de alguns truques adicionais.
Uma maneira de reconectar um shell existente (que não foi lançado com screen ou tmux ) é usar reptyr .
Do site do reptyr :
reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.
Você pode simplesmente usar o ID do processo (PID) e informar ao reptyr para reconectá-lo:
reptyr PID