如何从命令行关闭 Rserve

How to close Rserve from the command line

此问题与 close connection and perhaps also to this close Rserve 有关。但是,在后一种情况下,连接打开,在第一种情况下,答案没有指定如何 "kill" 服务器。

重要的是要说我是 Rserve 的新手,今天我第一次使用它进行一些温和的 R-python 交互。我从命令行启动 Rserve 为:

% R CMD RServe

我虽然在会话结束后关闭了连接,但是当我现在尝试使用新配置重新启动 Rserve 时,我收到错误消息:

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

这很清楚。此外 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 

据我所知,确实意味着服务器 运行ning。我尝试了一些事情:

% 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

最后

% R CMD shutdown
 shutdown: NOT super-user

我想知道,我是否应该运行:

% sudo R CMD shutdown

(我想在 运行 执行该命令之前确认一下,以防我搞砸了)

反正问题会很简单。我怎样才能关闭服务器重新运行它。

提前感谢您的宝贵时间!

你很困惑:

 R CMD something

将始终转到 R。并且 R 不再知道 Rserve 是 运行,即使您可能已经通过 R CMD Rserve 启动了它:这些现在是不同的进程.

你应该做的是

 kill 18177       # or possibly  kill -9 18177

并且有 kill 的包装器,它首先 grep 查找名称并为您找到 PID:

 killall Rserve   # or possibly  killall -9 Rserve

-9 发送比 SIGTERM 的默认值 -15 更高阶的 SIGKILL(即 'really go and die now')强度)(即 'please stop now' ).