Preserving Interactive Processes With Screen

I have an AWS instance, mainly for using emacs and org-mode outside when I have to use windows machine at work. Right now, it's giving me a chance to learn some more linux!

I usually run the same emacs session from work on this AWS instance, and I want to preserve and restore this emacs session quickly between ssh sessions.

Emacs desktops are not cutting it; not all processes/windows are maintained. Also, there's some overhead and management behind these that I don't need when a simpler solution is possible.

So I'm looking for a means of leaving the process up and reconnectable over logouts.

nohup is short for no hangup, i.e. this ignores the terminal hangup (logout) signal. But, as far as I understand, this doesn't leave interactive processes reconnectable. Similarly, the process can be run in the background with & or bg and disassociated from the user with disown, but this won't be preserved over sessions.

screen provides a way to preserve and resume interactive processes over sessions. Also, by default the processes run from a screen process are preserved when an SSH connection fails.

``` sh

# start up screen

# list screen sessions
screen list

# screen commands prefixed with <C>trl-a
C-a ?

# start up emacs
emacs ~/path/to/
# send emacs to background

# detach screen session (done automatically if ssh conn fails)
screen -d
# or
C-a d #detach

# resume screen session
screen -r
# bring emacs process back to foreground


Check out this helpful gem or man screen for more of its capabilities.

Go Top
comments powered by Disqus