在后台运行R [英] Running R in the background

查看:168
本文介绍了在后台运行R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个我不确定如何构图的问题.

Hi this is a question which i am not sure how to frame.

我正在从远程服务器运行R.我通过ssh @ username等访问远程服务器.访问后,我有一个命令提示符,我可以调用R,并且可以轻松地使用R.

I am running R from a remote server. My access to the remote server is via ssh@username and so on. After i access i have a command prompt which i invoke R and i am comfortable working on R.

问题1 我有一个大型网络(10万个节点),并希望进行社区检测,并希望在后台运行它,因此,如果我关闭终端,它会一直运行直到完成,然后将结果保存在我的R工作目录中.

Question 1 I have a large network (100k nodes) and would like to do community detection and would like to run it in the background such that if i close my terminal its keeps running until its finished saves the result in my R working directory.

我尝试使用nohup R&但我不确定该过程是否成功完成.

I have tried using nohup R & but i am not sure the process completed successful.

问题2 如果我设法实现问题1,如何继续使用R来执行其他任务?和

Question 2 If i manage to implement Question 1, how could i continue to use R to perform other task? and

问题3 如何检查Q1中的任务仍在运行.

Question 3 How do i check the task in Q1 is still running.

我对脚本的尝试如下

#!/usr/bin/env Rscript
library(igraph)
library(data.table)
edgebetween <- function(x) {
  simplify(x, remove.multiple = F, remove.loops = T) 
   edge.betweenness.community(x, directed = T)
}
community.a.g3 <- edgebetween(a.g3)

我已将脚本另存为我的工作主管

i have saved the script in my working director as a.R

,并在更改到我的工作目录后在命令提示符下使用 chmod + x a.R Nohup ./a.R&

and used at the command prompt after changing to my working directory chmod +x a.R nohup ./a.R &

我需要纠正什么.谢谢

推荐答案

您要在批处理"模式下执行R.请参阅( https://stat.ethz.ch /R-manual/R-devel/library/utils/html/BATCH.html )

You want to execute R in "batch" mode. See ( https://stat.ethz.ch/R-manual/R-devel/library/utils/html/BATCH.html )

以下命令是这些文档的示例. &"说与用户的登录会话分开运行",因此当您注销时,它将继续运行.

The command below is an example from those docs. The "&" says "run this separate from the user's login session" so when you log out, it continues to run.

R CMD BATCH [options] infile [outfile] &

您还可以按照此处的说明使用nohup( http://streaming.stat .iastate.edu/wiki/index.php/Running_Jobs_in_the_Background )

You can also use nohup as discussed here ( http://streaming.stat.iastate.edu/wiki/index.php/Running_Jobs_in_the_Background )

nohup R CMD BATCH ./myprog.R &

这篇关于在后台运行R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆