Interrupting R processes in Ubuntu

March 16, 2010
By

(This article was first published on The Praise of Insects, and kindly contributed to R-bloggers)

It's funny how things happen. Yesterday I was working away on a project in R and the unenjoyable happens---the process hangs for longer than desired. I operate R in the standard GNOME terminal in Ubuntu and the only way I knew was to close the entire application getting rid of all objects at the same time. Not cool. Thirty minutes or more of fruitless searching gave no indication as to a better way of doing things and I was really wishing the ESC key worked as it does in Windows.

Checking emails this morning though, and I discover an exchange on R-help that goes through exactly what I needed to know... From these emails then I have discovered that:
  • Pressing Ctrl+C should work in the terminal.
  • If that doesn't work, open another terminal console and type
    ps aux | grep R

    kill -s INT PID
  • The first line allows you to discover the PID number of your particular R instance, which is then used in the second line.
  • In the second line above, INT may be replaced by HUP in some cases.
  • The above methods set up an alert-thing to tell the program to stop. When the computations are done externally of R, it can't be executed before the external codes checks back with R. If the external code doesn't do this regularly or at all, killing the entire program is the only way out. If none of the above work, this is probably what has happened and it may be a good idea to let the package author know about the problem...
Thanks to all involved in this exchange: Adam Kramer, Duncan Murdoch, Simon Urbanek, Matthew Keller and Ted Harding

To leave a comment for the author, please follow the link and comment on his blog: The Praise of Insects.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.