[R] Running R on a server

jthetzel jthetzel at gmail.com
Tue Oct 12 05:40:16 CEST 2010


Sachin,

I apologize if I'm over-simplifying your question.  I mostly run R on an
Ubuntu server via a Windows laptop.  I log in to the remote server via SSH
(via PuTTY on Windows), and then open an interactive R session through the
usual ways (typing 'R' at the Linux command line).  When creating figures,
I'll usually just output the figures to pdfs, via pdf().  However, if I need
a more interactive experience with the figures, I'll ask PuTTY to initiate
'X11 forwarding', which, on Windows, also requires an X server, such as
Xming.  This causes plots to appear in new windows just like you were
running R on your local machine.

If you are interested in running non-interactive batch R scripts, reference
the following:
http://stat.ethz.ch/R-manual/R-devel/library/utils/html/BATCH.html .

Another note on running R over SSH: if you lose your SSH connection, the R
process will stop.  I get around this by using the 'screen' command in Linux
(http://en.wikipedia.org/wiki/GNU_Screen).  See man screen for details. 
While 'screen' does many things, relevant to this thread it creates new
remote terminals that persist after SSH disconnects.  After SSHing into my
server, I type 'screen' and [return], then 'R'.  R starts up and I start the
analysis.  I can manually 'detach' the screen by hitting the 'control' and
'a' keys together, and then hitting the 'd' key.  The R process (and any
other processes started in that screen session) will continue to run.  One
can start many screens.  Typing 'screen -ls' shows the currently running
screens.  If only one screen is running, typing 'screen -r' will attach that
screen, and one can continue on one's analysis in R.  If multiple screen
sessions are open, one will need to specify the screen name after the
'screen -r' command.  Sometimes after an abrupt disconnect, the screen will
remain attached, even though the SSH connection is lost.  To get back to the
screen session, one must first 'detach' and then 're-attach' the screen by
typing 'screen -dr'.

Let me know if you have more specific questions.

Cheers,
Jeremy

Jeremy Hetzel
Boston University
-- 
View this message in context: http://r.789695.n4.nabble.com/Running-R-on-a-server-tp2967748p2991084.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list