<div dir="ltr">I hit the send button a tad too soon.<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 17, 2013 at 10:21 PM, Jim Kinney <span dir="ltr"><<a href="mailto:jim.kinney@gmail.com" target="_blank">jim.kinney@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div>Sometimes I start a process that is going to take far longer than I'm willing to wait on and I forgot to load up a screen session to run in so if my VPN connection dies my process dies with it. Such is the life of an admin.<br>
<br></div>Here's a way to keep sanity a bit higher; transfer the pid to new screen session.<br><br></div>How?<br><br></div>Easy!<br><br></div>You need to have screen (you _do_ have screen, right? <a href="http://jimkinney.us/9.%2Bscreen.html" target="_blank">http://jimkinney.us/9.%2Bscreen.html</a>), reptyr (pronounced re-p-t-y-er) and be running in bash on the remote system.<br>
<br></div>In the shell where the long process is running, hit ctrl-z to pause the process and then run bg to background it.<br></div></div></div></div></div></blockquote><div><br></div><div>Now run the bash shell command 'disown <pid of log process>' to fully detach the process from the parent.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div></div>Now in another shell on the same system, start a screen session with 'screen'.<br>
</div>In the screen session, run 'reptyr <pid of long process>'<br></div>Now you can ctrl-a d and get off the system entirely and the process will run in the new screen session.<br><br></div>Note: retty (old school version of reptyr) is replaced by reptyr as retty is not happy at all with x86_64.<span class="HOEnZb"><font color="#888888"><br clear="all">
</font></span></div></blockquote><div><br></div><div>Note2: The disown command usage will not appear in your history after it's run so it's not possible to grep history for "how did I do that?" later.<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="HOEnZb"><font color="#888888">
<div><div><div><div><div><div><div><div><div><div><br>-- <br><div dir="ltr">-- <br>James P. Kinney III<br><i><i><i><i><br></i></i></i></i>Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.<br>
- Speech 11/23/1900 Mark Twain<br><i><i><i><i><br><a href="http://heretothereideas.blogspot.com/" target="_blank">http://heretothereideas.blogspot.com/</a><br></i></i></i></i></div>
</div></div></div></div></div></div></div></div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">-- <br>James P. Kinney III<br><i><i><i><i><br></i></i></i></i>Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.<br>
- Speech 11/23/1900 Mark Twain<br><i><i><i><i><br><a href="http://heretothereideas.blogspot.com/" target="_blank">http://heretothereideas.blogspot.com/</a><br></i></i></i></i></div>
</div></div></div>