[ale] How to move a running process to screen session

David Tomaschik david at systemoverlord.com
Tue Dec 17 23:44:04 EST 2013


fg only works within the same pty, screen allocates new pty(s).  Also,
closing the external session would send SIGHUP to any process in the
process group.


On Tue, Dec 17, 2013 at 8:17 PM, Bruno Bronosky <richard at bronosky.com>wrote:

> Do you really need reptyer? I would have tried to do this with fg <pid>
>
> Not sure if it works as I'm pretty consistent at running tmux (what the
> cool kids use in place of screen these days)
> On Dec 17, 2013 10:29 PM, "Jim Kinney" <jim.kinney at gmail.com> wrote:
>
>> I hit  the send button a tad too soon.
>>
>>
>> On Tue, Dec 17, 2013 at 10:21 PM, Jim Kinney <jim.kinney at gmail.com>wrote:
>>
>>> 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.
>>>
>>> Here's a way to keep sanity a bit higher; transfer the pid to new screen
>>> session.
>>>
>>> How?
>>>
>>> Easy!
>>>
>>> You need to have screen (you _do_ have screen, right?
>>> http://jimkinney.us/9.%2Bscreen.html), reptyr (pronounced re-p-t-y-er)
>>> and be running in bash on the remote system.
>>>
>>> In the shell where the long process is running, hit ctrl-z to pause the
>>> process and then run bg to background it.
>>>
>>
>> Now run the bash shell command 'disown <pid of log process>' to fully
>> detach the process from the parent.
>>
>>
>>> Now in another shell on the same system, start a screen session with
>>> 'screen'.
>>> In the screen session, run 'reptyr <pid of long process>'
>>> Now you can ctrl-a d and get off the system entirely and the process
>>> will run in the new screen session.
>>>
>>> Note: retty (old school version of reptyr) is replaced by reptyr as
>>> retty is not happy at all with x86_64.
>>>
>>
>> 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.
>>
>>>
>>> --
>>> --
>>> James P. Kinney III
>>>
>>> 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.
>>> - Speech 11/23/1900 Mark Twain
>>>
>>>
>>> *http://heretothereideas.blogspot.com/
>>> <http://heretothereideas.blogspot.com/>*
>>>
>>
>>
>>
>> --
>> --
>> James P. Kinney III
>>
>> 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.
>> - Speech 11/23/1900 Mark Twain
>>
>>
>> *http://heretothereideas.blogspot.com/
>> <http://heretothereideas.blogspot.com/>*
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>


-- 
David Tomaschik
OpenPGP: 0x5DEA789B
http://systemoverlord.com
david at systemoverlord.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20131217/cac1e273/attachment.html>


More information about the Ale mailing list