# scheduling scripts

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In most cases, you’ll write a R script that pulls data, manipulates it and dumps the output to a database or you’ll create a beautiful report in rmarkdown. Suppose you want to run this script or report every day, week, day, etc. Well, there are a few possibilities for automating these procedures on Windows machine.

You can use the default windows task scheduler. To do so, you can create a cmd file including the path to your Rscript.exe and the path to your R script: "yourpathto\...\R\bin\Rscript.exe" "yourpathto\...\myRscript.R". You can also add a log output "yourpathto\...\R\bin\Rscript.exe" "yourpathto\...\myRscript.R" >> "yourpathto\...\logfile.txt. Next, add this cmd file as a new task to your windows scheduler and define the trigger conditions. Or you can do this directly withing the windows scheduler.

taskscheduleR is a recently released R package that will schedule your R scripts using SCHTASKS, a commandline front-end for windows’ task scheduler. This package includes most functions such as returning a list of scheduled tasks taskscheduler_ls(), removing a task taskscheduler_delete() and ofcourse adding a new task taskscheduler_create(). Take a look at the official blog-post from Jan Wijfels at: R package to schedule R scripts with the Windows task manager.