re-parenting a shell command

let’s say you’ve logged in via ssh to some server and started some long running command. minutes or hours later you’ve realized that you did not run it under screen or tmux – so that command will die once your ssh connection is closed. today i’ve learned about reptyr which can help with that – it allows to take over another command e.g. to push it take it over into screen session.

in one ssh session, without screen/tmux, i’m running:

xz -kv a_large_file.sql

to take it over – in another windows, this time within tmux/screen session:

ps faux|grep xz
reptyr 1234

that’s it, now command continues to run with output coming to the terminal multiplexer. it’ll run even if my ssh session breaks.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)