Return R Script Log From Scheduling - r

I have scheduled an RScript to run via the TaskScheduler but there seems to be an error occurring in the code which does not occur when I run the code manually.
Is there a way I can output the RScript log into a separate file so I can then debug?

Related

Running R Scripts With Windows Task Scheduler

I am attempting to run a saved R script using Windows Task Scheduler. When I run it it fails. In an attempt to troubleshoot the problem I created a small test R script
test <- function(){
print("test")
}
test()
I then create a small bat file with
"C:\R\R-3.4.4\bin\R.exe" "C:\Test.R"
When I attempt to manually run that .bat file R in the cmd line opens but its initial message is
"C:\R\R-3.4.4\bin\R.exe" "C:\Test.R"
ARGUMENT "C:\Test.R" __ignored__
and the script does not run.

R script does not run within Slurm batch job

I am running a script that starts as follows:
#!/usr/bin/env Rscript
#./geneiase -t static -i mydata.tab
If I run the script on my data directly in the command line, it starts without errors or warnings.
But the program is very demanding computationally so I need to submit my jobs to a cluster using a job scheduler called Slurm.
When I write the exact same expression (as in the second paragraph) within the batch job file, and then I submit the job using sbatch, it is immediatelly terminated and does not return any error or output that can help me understand the problem.
I think it has to do with having Rscript in $PATH, but even though I added the directory where Rscript is located to $PATH by: PATH=$PATH:path/to/R/build/R-3.4.0/lib64/R/bin, the problem remains.
Is there a way that I can make Rscript be run in a Slurm batch job?
You'll need to keep the environment of your SLURM script as bash
#!/bin/bash
Since you can run your R script from the command line, it likely means the path to R is already included in your $PATH. On the command line, you might already do something like:
Rscript ./path-to-script/script
To run R from within your SLURM script, it's the same as running from the command line:
Rscript ./path-to-script/script

Run R script using batch file

I'm attempting to schedule an R script as mentioned in
the Scheduling R Script stackoverflow answer but I keep getting an error that says
ARGUMENT 'BATCH' \__ignored__
ARGUEMENT 'C:/Users/cburton/AutomaticJobPuller/jobsPuller.R' \__ignored__
and then it has the startup prompt for the R programming environment.
The contents in my batch file are
C:\Users\cburton\Documents\R\R-3.2.0\bin\R.exe BATCH C:\Users\cburton\AutomaticJobPuller\jobsPuller.R --vanilla
This is my first batch file, so I'm sure it's something simple, but I can't find the answer to this.

Error in scheduling R script

We are trying to schedule an R script using windows task scheduler.
location of R C:\Program Files\R\R-3.1.0\bin\R.exe
Location of my script D:\K-exercise\k-demo.R
These are the steps that we are following:
Task scheduler--Actions--new--program script--location of cmd.exe--arguments--"C:\Program Files\R\R-3.1.0\bin\R.exe" CMD BATCH "D:\K-exercise\k-demo.R"--triggered the time
Command prompt is opening but is not sure whether the script it is running or not?
We are not able to see any output.
Can someone help here?

Rscript logfile with input, errors and output

Is there a way to fully log (stdin, stdout, stderror) a R session executed via Rscript in batch mode?
I know, that I can use R CMD BATCH to log the full session of a batch job. I also know how to write errors and output into a logfile using Rscript but since it is often said that R CMD BATCH is a relict from the old days and one should use Rscript, I was wondering if it can also log everything.
I suppose it is impossible but I am not sure - neither do I know why.

Resources