R Script Planning

I wrote an R script that retrieves some data from a database, performs several operations on it, and publishes the output to a new database.

I would like this script to run every day at a specific time, but I cannot find a way to do this efficiently.

Can someone recommend a resource that I could pay attention to solve this problem? I run this script on a windows machine.

+97
windows r r-faq schedule
May 08 '10 at 8:16
source share
6 answers

In fact, under Windows you don’t even need to create a batch file to use Scheduler .

  • Open the scheduler: START β†’ All programs β†’ Accessories β†’ System tools β†’ Scheduler
  • Create a new task
  • in the "Action" section, create a new action
  • select Run program
  • look for rscript.exe which should be located, for example. Here:
    "C: \ Program Files \ R \ R-3.0.2 \ bin \ x64 \ Rscript.exe"
  • enter the name of your file in the parameters field
  • enter the path where the script is in the Start in field
  • go to the Triggers tab.
  • create a new trigger
  • choose that the task should be performed every day , month, ... repeated several times or what you like
+98
Feb 04 '14 at 9:24
source share

Assuming your R-script is mytest.r located in D:\mydocuments\ , you can create a batch file that includes the following command:

 C:\R\R-2.10.1\bin\Rcmd.exe BATCH D:\mydocuments\mytest.r 

Then add it, as a new task, to the Windows Task Scheduler, setting the launch conditions there.

You can also omit the batch file. Set C:\R\R-2.10.1\bin\Rcmd.exe in the program/script text box in the task scheduler and specify the rest of the initial command as Arguments : BATCH D:\mydocuments\mytest.r

Scheduling R Tasks Using the Windows Task Scheduler (Published February 11, 2015)

taskscheduleR: R package for scheduling R scripts using the Windows task manager (Published March 17, 2016)

EDIT

Recently, I again accepted the use of batch files because I wanted the cmd window to be minimized (I could not find another way).

In particular, I populate the Actions tab of the Windows Task Scheduler as follows:

Program/script:

cmd.exe

Add arguments (optional):

/ c start / min. D: \ mydocuments \ mytest.bat ^ & exit

The contents of mytest.bat:

C: \ R \ R-3.5.2 \ bin \ x64 \ Rscript.exe D: \ mydocuments \ mytest.r params

+57
May 08 '10 at 10:02
source share

I set my tasks using the SCHTASKS program. To run scripts at startup, you must write something along the lines

 SCHTASKS /Create /SC ONSTART /TN MyProgram /TR "R CMD BATCH --vanilla d:\path\to\script.R" 

For more information on SCHTASKS see this site . Learn more at the Microsoft website .

+4
Jul 16 '11 at 15:07
source share

You can use the Windows Task Scheduler .

+3
May 08 '10 at 8:19
source share

Now for this there is a built-in option in RStudio, to start the scheduler, first install the following packages

  install.packages('data.table') install.packages('knitr') install.packages('miniUI') install.packages('shiny') install.packages("taskscheduleR", repos = "http://www.datatailor.be/rcube", type = "source") 

After installation, go to

 **TOOLS -> ADDINS ->BROWSE ADDINS ->taskscheduleR -> Select it and execute it.** 

enter image description here

+2
Feb 21 '19 at 5:51
source share

After doing any combination of these steps and getting the "Argument Batch Ignored" error after starting R.exe, try this, it worked for me.

In Windows Task Scheduler:

Replace BATCH "C:\Users\desktop\yourscript.R" in the argument field

from

CMD BATCH --vanilla --slave "C:\Users\desktop\yourscript.R"

0
Aug 07 '17 at 20:44 on
source share



All Articles