Moving a running process to tmux

Situation: 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:

  1. Install reptyr
  2. Ctrl+Z to pause the process
  3. bg to move the process into background
  4. disown %1 to give up ownership of the process
  5. tmux
  6. pgreg process_name to find the PID of the disowned process
  7. reptyr PID to “own” the process in the new tmux window
  8. detach tmux session and enjoy

Source: “Move a running process to screen” by Bruce Werdschinski