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
bg
to move the process into backgrounddisown %1
to give up ownership of the processtmux
pgreg process_name
to find the PID of the disowned processreptyr PID
to “own” the process in the new tmux window- detach tmux session and enjoy
Source: “Move a running process to screen” by Bruce Werdschinski