Este é um blog onde anoto dicas técnicas de informática e computação. This is a blog where I write down technical tips on computing. Be aware that some resources used in this blog may use cookies to collect information used by Ads and Google Analytics. I do not monetize from this website, neither require or use personal information.
Monday, September 21, 2015
Background -> Disown -> Foreground process in linux with reptyr
reptyr - A tool for "re-ptying" programs.
reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.
USAGE
reptyr PID
"reptyr PID" will grab the process with id PID and attach it to your current terminal.
After attaching, the process will take input from and write output to the new terminal, including ^C and ^Z. (Unfortunately, if you background it, you will still have to run "bg" or "fg" in the old terminal. This is likely impossible to fix in a reasonable way without patching your shell.)
Example:
$ top
^Z
$ bg
[1]+ top &
[1]+ Stopped top
$ disown
$ fg
bash: fg: current: no such job
$ pidof top
13675
$ reptyr 13675 ( before you can start another screen instead of the same)
And Voila! Process is back to the foreground
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment