I have written an R script that pulls some data from a database, performs several operations on it and post the output to a new database.
I would like this script to run every day at a specific time but I can not find any way to do this effectively.
Can anyone recommend a resource I could look at to solve this issue? I am running this script on a Windows machine.
Actually under Windows you do not even have to create a batch file first to use the Scheduler.
"C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe"
I set up my tasks via the
SCHTASKS
program. For running scripts on startup, you would write something along the lines ofSee this website for more details on
SCHTASKS
. More details at Microsoft's website.Supposing your R script is
mytest.r
, located inD:\mydocuments\
, you can create a batch file including the following command:Then add it, as a new task, to windows task scheduler, setting there the triggering conditions.
You could also omit the batch file. Set
C:\R\R-2.10.1\bin\Rcmd.exe
in theprogram/script
textbox in task scheduler, and give asArguments
the rest of the initial command:BATCH D:\mydocuments\mytest.r
Scheduling R Tasks via Windows Task Scheduler (Posted on February 11, 2015)
taskscheduleR: R package to schedule R scripts with the Windows task manager (Posted on March 17, 2016)
You can use Windows Task Scheduler.
After following any combination of these steps and you receive the
"Argument Batch Ignored"
error after R.exe runs, try this, it worked for me.In Windows Task Scheduler:
Replace
BATCH "C:\Users\desktop\yourscript.R"
in the arguments fieldwith
CMD BATCH --vanilla --slave "C:\Users\desktop\yourscript.R"