1

I'm running R script in OpenCPU/Docker and looking for the way how I can run the script that will create background process and returning back the message that the process has started. Something like this:

fun1<-function(arg1,arg2){

#calling different function to run in background, using arg1/arg2, no need 
#of result now, I will check the result through the file later
     fun2(arg1,arg2)

     return('Process has started')
}

How can I run the fun2 in the background? All functions are inside the package and I have tried Rscript but with no success. Any ideas or packages for this? I believe a lot of people already went thru this.

John Snow
  • 153
  • 7
  • you might take a look at http://stackoverflow.com/questions/18306362/run-r-script-from-command-line – Josh Beauregard May 02 '17 at 14:56
  • Thanks but I don't want to run it via command line - I need to trigger background process via R code. I've tried system("Rscript '\"source(\"fun2.R\")'", wait=FALSE) but I need to pass the arguments as well. Even if I run simple command system("Rscript '\"test.R'", wait=FALSE) just to create dummy file, it doesn't work. – John Snow May 03 '17 at 06:58
  • what about just adding & at the end of your Rscript command – Josh Beauregard May 03 '17 at 12:54
  • could you give me an example please? – John Snow May 03 '17 at 13:09
  • `Rscript FILENAME &` see https://bash.cyberciti.biz/guide/Putting_jobs_in_background – Josh Beauregard May 03 '17 at 13:57

0 Answers0