在Linux上以批处理模式运行R:输出问题 [英] Running R in Batch Mode on Linux: Output Issues

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

问题描述

我正在linux集群上运行R程序,因为它对我的处理器要求很高.我的程序旨在将PDF格式的多个图(约15个)输出到该程序从中收集其输入的文件夹中.

I'm running an R program on a linux cluster because it is very demanding on my processor. My program is designed to output multiple (around 15) plots as PDF's into the folder from which the program gathers its input.

我希望我的程序在后台运行,并在退出集群时继续运行.

I want my program to run in the background, and to continue running when I log out of the cluster.

首先,我尝试过:

cd /Users/The/Folder/With/My/RScript #changed working directory
nohup ./BatchProgram.R &

但是,这没有用,因为它将输出附加到了名为nohup.out的文件中,并且没有输出我需要的任何PDF.

However, this didn't work because it appended the output to a file called nohup.out, and did not output any of the PDF's I need.

接下来,我尝试了此操作:

Next I tried this:

cd /Users/The/Folder/With/My/RScript #changed working directory
R #to run R
source(‘BatchProgram.R’) #to run my program

这给了我想要的输出,但是没有在后台运行程序(并且当我退出集群时会停止).

This gave me the desired output, but didn't run the program in the background (and would stop when I logged out of the cluster).

有人可以启发我如何在后台运行程序的同时获取第二个代码块的输出,即使在我退出linux集群后,也使它继续运行(例如第一个代码块).代码)?

Could someone enlighten me as to how I might obtain the output of my second block of code, while running the program in the background AND causing it to continue running even after I log off of the linux cluster (like the first block of code)?

非常感谢!

推荐答案

nohup在后台运行命令,使其忽略告诉其停止的信号(例如,当您注销时),并将输出重定向到文件. 但这必须是一个可执行命令:nohup.out中可能有错误消息,告诉您BatchProgram.R无法运行.

nohup runs a command in the background, makes it ignore signals telling it to stop (e.g., when you log off), and redirects the output to a file. But it has to be an executable command: you probably have error messages in nohup.out telling you that BatchProgram.R could not be run.

以下应能工作:

nohup Rscript ./BatchProgram.R &

这篇关于在Linux上以批处理模式运行R:输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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