0

I am attempting to use windows task scheduler to run my R script. When I setup the task, I can see the CMD window opens, and my packages start to load...but then the cmd just closes and the task never completes. When I schedule a very simple script, it works just fine. Does it have to do with the length of my script? Or the packages? Not really sure what to do here...any help would be greatly appreciated.

thelordmcd
  • 11
  • 3
  • This lacks enough detail for us to help. To provide a detailed answer, one would need info about your R setup, your environment variables (does R lie in the System environment "PATH" variable) and potentially if you are working on an external machine with multiple logins (which can cause issues with paths to personal folders and external drives). – Oliver Sep 01 '22 at 13:33
  • The R HOME path in Rstudio and R match. The libraries are all present in both. There are not multiple logins. I can't even run the script using a BAT file. You can see it starts..but looks like its hanging. – thelordmcd Sep 01 '22 at 13:52
  • It is always difficult to debug non-interactive code bugs. Usually you'd debug the code with `browser`, `debug` and so on, here I'd suggest logging steps in your code to see how far it gets before crashing. Does it start? Does it get to key-points in your code? You can use a package solution like [logger](https://cran.r-project.org/web/packages/logger/), [logging](https://cran.r-project.org/web/packages/logging/) or do it with `writeLines`. Alt. try standard [debugging](https://stackoverflow.com/questions/57668869/is-there-a-way-to-debug-an-r-script-run-from-the-command-line-with-rscript-exe) – Oliver Sep 01 '22 at 14:24

0 Answers0