title: How to close Rserve from the command line
body: <p>this question relates to <a href="https://stackoverflow.com/questions/23264328/connection-of-java-and-r-with-rserve">close connection</a> and perhaps also to this <a href="https://stackoverflow.com/questions/26225066/how-can-i-shut-down-rserve-gracefully">close Rserve</a>. However, in the later case there are connections open and in the first case the answer does not specify how to "kill" the server. </p>
  
  <p>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:</p>
  
  <pre><code>% R CMD RServe
  </code></pre>
  
  <p>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: </p>
  
  <pre><code>% ##&gt; SOCK_ERROR: bind error #48(address already in use)
  </code></pre>
  
  <p>which is pretty clear. Moreover <code>ps ax | grep Rserve</code> returns:</p>
  
  <pre><code>% ps ax | grep Rserve
  18177   ??  Ss     0:00.33 /Library/Frameworks/R.framework/Resources/bin/Rserve
  18634 s006  U+     0:00.00 grep Rserve 
  </code></pre>
  
  <p>which I understand that indeed means that the server is running. I have tried a few things: </p>
  
  <pre><code>% 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
  </code></pre>
  
  <p>and finally</p>
  
  <pre><code>% R CMD shutdown
   shutdown: NOT super-user
  </code></pre>
  
  <p>I am wondering, should I then run: </p>
  
  <pre><code>% sudo R CMD shutdown
  </code></pre>
  
  <p>(I would like to make sure before running that command, in case I screw something) </p>
  
  <p>Anyway, the question would be very simple. How can I close server to re-run it. </p>
  
  <p>Thanks in advance for your time!</p>