Running R in the background

旧时模样 提交于 2019-12-04 13:53:07

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] &

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 &

Bit late but if other needs an answer. Do this: Save your script, I'll use Test.R as example.

head Test.R
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)

use screen then run Rscript Test.R and hit ctrl + a + d. when you come back do screen -ls, and then screen -r <Number of your screen session>. Voila!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!