scheduling scripts

April 23, 2017
By

(This article was first published on R on Know Your Data, and kindly contributed to R-bloggers)

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.

Windows Task Scheduler:

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.

There’s a nice tutorial on youtube if you want to learn more about the basics: Scheduling R Tasks via Windows Task Scheduler

TaskscheduleR

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.

Rstudio addin TaskscheduleR

The source code of taskscheduleR is avaible on github and i just pushed a Rstudio Addin for this package. This will allow you to add/stop/remove your task with a clean and easy UI. It also keeps a central repository for your R tasks so that you can easily edit the original script. You only need to overwrite the existing task of the same name. I’ve included a task check which will indicate if the uploaded script already exists.

Addin a new task

ScheduleR

Lastly, scheduleR is a schedule framework created by Bart Smeets and has been tested under GNU/Linux and Windows. It’s designed to be an intuitive interface for scheduling R scripts and Rmarkdown files, but also for deploying shiny apps. Yes, shiny apps! It comes with a nice web interface using Node.js and mongodb as back-end. What makes this framework so special? It has a great interface, comes with user management, keeps track of detailed logging and status reports. These status reports and the Rmarkdown reports can be send directly via email to a list of recipients or to a file directory.

To leave a comment for the author, please follow the link and comment on their blog: R on Know Your Data.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)