2

I am attempting to use Windows Task Scheduler to automatically run R code daily using instructions from another StackOverflow question (Scheduling R Script). Window Task Scheduler correctly opens Rscript.exe and begins running the code; however, after a few lines of code it gives the error "Error: Memory Exhausted (limit reached?)" and stops running. I am able to execute this code in RStudio manually with no memory errors.

I have tried the following solutions based on various StackOverflow answers with no success:

  • Increase memory priority of scheduled task (from original 7 to highest 4)
  • Add library(methods) to R code
  • Increase memory in R with Sys.setenv(R_MAX_VSIZE=16e9)
  • Increase memory in .Renviron by adding R_MAX_VSIZE=100GB in RStudio

1 Answers1

0

So, the code executes in RStuio with no problems whatsoever. Also, the .exe runs fine when you double-click it, right. This may be a permissions issue. Make sure the password is correct in the Task Scheduler. If you enter the wrong password for your machine, I don't think the Task Scheduler will prompt you, so you can easily enter the wrong password and not even know it (that's the way it used to be; maybe MS fixed this bug). Check the logs for some ideas of what's going on when the process crashes. Post back with your findings.

ASH
  • 20,759
  • 19
  • 87
  • 200
  • I just tried running just the .exe file (not with Task Scheduler) and am running into the same problem. It appears running with .exe is causing the issue. Any ideas on how to fix this? – charlotte123 Feb 06 '20 at 13:20
  • Now it makes more sense. I just looked on my laptop for some sample code to share with you. I didn't find any code, but I know you can do this. I think there is a 3rd party app that you can use to create an EXE from r code. If you Google for it, you should find something quickly and easily. It has been a long time since I did this, but I know it's possible, so just keep at it until you get it working. – ASH Feb 06 '20 at 16:47