Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close Rserve from the command line

Tags:

r

rserve

this question relates to close connection and perhaps also to this close Rserve. However, in the later case there are connections open and in the first case the answer does not specify how to "kill" the server.

It is important to say that I am new to Rserve, and I have used it for the 1st time today for some mild R-python interaction. I started Rserve from the command line as:

% R CMD RServe

I though I had closed the connection after the session, but when I now try to re-start Rserve again with a new configuration I get the error:

% ##> SOCK_ERROR: bind error #48(address already in use)

which is pretty clear. Moreover ps ax | grep Rserve returns:

% ps ax | grep Rserve
18177   ??  Ss     0:00.33 /Library/Frameworks/R.framework/Resources/bin/Rserve
18634 s006  U+     0:00.00 grep Rserve 

which I understand that indeed means that the server is running. I have tried a few things:

% R CMD RSclose
 /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: RSclose: not found

% R CMD RSshutdown
 /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: RSshutdown: not found

and finally

% R CMD shutdown
 shutdown: NOT super-user

I am wondering, should I then run:

% sudo R CMD shutdown

(I would like to make sure before running that command, in case I screw something)

Anyway, the question would be very simple. How can I close server to re-run it.

Thanks in advance for your time!

like image 917
Javier Avatar asked May 05 '15 12:05

Javier


1 Answers

You are confused:

 R CMD something

will always go to R. And R no longer knows Rserve is running even though you may have started it via R CMD Rserve: these are now distinct processes.

What you should do is

 kill 18177       # or possibly  kill -9 18177

and there are wrappers to kill which first grep for the name and find the PID for you:

 killall Rserve   # or possibly  killall -9 Rserve

The -9 sends a higher-order SIGKILL (ie 'really go and die now') intensity than the default of -15 for SIGTERM) (ie 'please stop now').

like image 60
Dirk Eddelbuettel Avatar answered Oct 14 '22 00:10

Dirk Eddelbuettel