taskscheduleR: R package to schedule R scripts with the Windows task manager

(This article was first published on BNOSAC - Belgium Network of Open Source Analytical Consultants, and kindly contributed to R-bloggers)

If you are working on a Windows computer and want to schedule your R scripts while you are off running, sleeping or having a coffee break, the taskscheduleR package might be what you are looking for. 

taskscheduleR-logo

The taskscheduleR R package is available at https://github.com/jwijffels/taskscheduleR and it allows R users to do the following:

i) Get the list of scheduled tasks

ii) Remove a task

iii) Add a task

    – A task is basically a script with R code which is run through Rscript

    – You can schedule tasks ‘ONCE’, ‘MONTHLY’, ‘WEEKLY’, ‘DAILY’, ‘HOURLY’, ‘MINUTE’, ‘ONLOGON’, ‘ONIDLE’

    – After the script has run, you can check the log which can be found at the same folder as the R script. It contains the stdout & stderr of the Rscript.

 

Below, you can find an example how you can schedule your R script once or daily in the morning. 
library(taskscheduleR)
myscript <- system.file(“extdata”, “helloworld.R”, package = “taskscheduleR”)

## run script once within 62 seconds
taskscheduler_create(taskname = “myfancyscript”, rscript = myscript,
schedule = “ONCE”, starttime = format(Sys.time() + 62, “%H:%M”))
## run script every day at 09:10
taskscheduler_create(taskname = “myfancyscriptdaily”, rscript = myscript,
schedule = “DAILY”, starttime = “09:10”)

## delete the tasks
taskscheduler_delete(taskname = “myfancyscript”)
taskscheduler_delete(taskname = “myfancyscriptdaily”)

  • When the task has run, you can look at the log which contains everything from stdout and stderr. The log file is located at the directory where the R script is located. 
## log file is at the place where the helloworld.R script was located
system.file(“extdata”, “helloworld.log”, package = “taskscheduleR”)

Who wants to set up an RStudio add-in for this?

To leave a comment for the author, please follow the link and comment on their blog: BNOSAC - Belgium Network of Open Source Analytical Consultants.

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.

Sponsors

Mango solutions



RStudio homepage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



http://www.eoda.de







ODSC

ODSC

CRC R books series











Contact us if you wish to help support R-bloggers, and place your banner here.

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)