Moving a running process to tmux
07 Nov 2022Situation: you started a process on a terminal and find that it runs way longer than expected. Suddenly you wish you had started this in a tmux session.
Solution:
- Install reptyr
- Ctrl+Z to pause the process
- bgto move the process into background
- disown %1to give up ownership of the process
- tmux
- pgreg process_nameto find the PID of the disowned process
- reptyr PIDto “own” the process in the new tmux window
- detach tmux session and enjoy
Source: “Move a running process to screen” by Bruce Werdschinski