[R] Auto execute R script

Cedrick W. Johnson cedrick at cedrickjohnson.com
Thu Nov 12 21:43:45 CET 2009


This is on windows I am assuming? On linux, you can write a script, then 
have cron execute it, similar to below, only I think you need to replace 
Rterm with R CMD or something.

Put this in a batch file, and create a scheduled task. Make sure to put 
the "start in" or "working directory" to the same as where your R script is.

This requires that you have %R_HOME% added to your path (on Windows at 
least)

Rterm --verbose --no-restore --file=MorningStartup.r > 
morningsummary-log.txt

Replace MorningStartup.r and morningsummary-log.txt with your R script 
and a log file name of your choice.

HTH
cedrick


Jason Gasper wrote:
> Greetings,
> I am hoping someone can help me with a automation task.  I would like 
> to auto-run a script at a scheduled time each night. Basically, this 
> auto-run would would call sqlQuery() and save the results of some math 
> to a table- basically archiving a live database table.  Has anyone 
> done this before using R? Perhaps the way to approach this is through 
> the editor, but I don't see anything in Tinn that would provide this 
> capability.  Further the editor would need to be opened (which I guess 
> could be done through windows task scheduler) and the R code would 
> then need to be ran.
> It seems clunky, but some of the statistics cannot easily be done in 
> our database environment.
>
> Thanks-Jason
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list