this is my situation: I usually run R
from within Emacs
using ESS
into terminal emulator, in my local pc. In my work place we get a new server running R
so I would use the remote server via ssh
. I connect via ssh
and all works well. What I would do is to keep alive the R
console while I close my laptop and go home so, from my home I would reconnect to the existing R
session.
I tried to put the R
console in background using C-q C-z Enter
to stop the process but, while I close the ssh connection the proces is killed. No luck using bg &
too. I also tried mosh
but, also in this case, I get some issue related to the UDP traffic across my work's network. Screen
and tmux
are not also very useful due to their bad interaction with the Emacs eshell
.
In both client and server machine I run Debian 8 xfce.
Is there a way to keep alive the R terminal while closing the ssh connection? Which is your approach to the long R sessions?
EDIT
Finally here and here I found the solutio that I'm looking for. I tried the same approach as in the link above, but using tmux, and I get lots of error. The holy grail is screen. I tried to follow step-by-step that procedure but I get an error from emacs while I try to attach a screen session from within eshell. So I tried to use ansi-term instead of eshell and all works as expected. I can attach and detach the R session. In this way I use the remote server machine only for the computation while the R scripts are in my laptop. So, this is the work-flow:
ssh
to the host serverscreen
sessionR
screen
emacs
as daemon in your local machine and open an emacsclient
instance (not necessary run emacs via emacsclient but I prefer this
way)R
scriptansi-term
(M-x ansi-term
)ssh
to the server from ansi-term
screen -r
)R
console to the local R
script (M-x ess-remote
)Ctrl-q Ctrl-a d return
Thats it. Now I can run a remote R
process using a local R
script, closing the connection but leaving open the R
console so I can re-attach to it in the future, also from a different IP.
This is one of my favourite topics :) Here is what I do:
emacs --daemon
so that it runs in the background.emacsclient -nw
(for textmode) or emacsclient -c
(in x11/graphical mode) to access the daemonized emacs in the background. I have these aliased to emt
and emx
, respectively.Now you are essentially done. You can ssh
to that box and resume from whereever you can launch ssh
from---which may be a smartphone or browser. And ESS of course allows you to have multiple R sessions. After M-x R
I often invoke M-x rename-buffer
to align the buffer with the project name or idea I work on.
I combine this further with both
byobu
(which is a fancy tmux
wrapper available in many distros and on OS X, and originally from Ubuntu) to have shell sessions persistmosh
for places like work and home where my laptop can simply resumeStrictly speaking you do not need byobu
or mosh
for emacs
to persist (as running the daemon takes care of that) but you may want it for all your other shell session.
This setup has been my goto tools for years at work and home.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With