How to disown and then re-claim a runinng process in another terminal/shell window with bash

  • Start a long running process, e.g. “scp .
  • Background the process with CTRL-Z
  • Resume the process in the background: bg
  • Disown the jobs from the current parent with disown %1. After that, jobs will not show the job any more, but “ps -a” or “ps -ef” will.
  • Start your terminal multiplexer of choice, e.g. screen
  • Display your running background jobs with “jobs -l“, this should look like this:

[1]+ 24494 Stopped (signal) scp
(The -l in jobs -l makes sure you’ll get the PID)
Run “screeen”

  • Now run “reptyr 24494”, and then simply press “CTL-A D” to exit.
  • Reattach to the back-grounded process: “reptyr 24494”
  • Detach your terminal multiplexer (e.g. CTRL-A D) and close ssh
  • Reconnect ssh, attach to your multiplexer (e.g. retty).

No comments yet.

Leave a Reply