reptyr is a wonderful little utility for Linux systems which enables you to reattach long running processes in screen or tmux. Great if you started something and have to close ssh.
In order to install, you need to clone the repository, run make and copy the reptyr
binary to some directory in your $PATH
. Typical usage works like this:
- Start a long running process, e.g.
top
- Background the process with CTRL-Z
- Resume the process in the background:
bg
- Display your running background jobs with
jobs -l
, this should look like this:[1]+ 4711 Stopped (signal) top
- (The
-l
injobs -l
makes sure you'll get the PID)
- Disown the jobs from the current parent with
disown top
. After that,jobs
will not show the job any more, butps -a
will. - Start your terminal multiplexer of choice, e.g.
tmux
- Reattach to the backgrounded process:
reptyr 4711
- Detach your terminal multiplexer (e.g. CTRL-A D) and close ssh
- Reconnect ssh, attach to your multiplexer (e.g.
tmux attach
), rejoice!
I think reptyr is the perfect companion for tmux and should be installed on every Linux box, just like tmux.