Move a running process to a new screen shell

Linux Logo

The purpose of this article is to show you how to move a process from your traditional shell to a new screen session.


  1. The first thing to do is to suspend the process. In my case, mv can be suspended by typing ctrl+z.

  2. Secondly, resume the process in background:
    $ bg

  3. Now, we will detach the process from its parent (the shell). So, when the parent process will be terminated, the child (mv) will be able to continue. For this, we use the disown builtin:
    $ disown mv

  4. Launch a screen session:
    $ screen

  5. As we are in a screen session, we will retrieve the mv process. To do so, we use the reptyr command which take a pid:
    $ reptyr <pid>

  6. To avoid the tedious pid research, we can use the pgrep command:
    $ reptyr $(pgrep mv)

Now the process is in a screen shell, we can safely detach our session and no longer worry about killing our X server or close our ssh connection.