[R] Windows Task Scheduler and R updates. Need basic tips

Joshua Wiley jwiley.psych at gmail.com
Thu May 17 22:06:32 CEST 2012


Hi Paul,

This is a bit OT, but here's what I would do.

1) write the R script (or if updating packages is all you want Rscript
-e "update.packages(repos = 'yourrepo', ask = FALSE)" would do it
without need for a script)

2) write a silly batch file (e.g., Rupdate.bat) wrapper (maybe there
are better ways, but this is easy) that contains the command to have R
execute the R script (becomes slightly less silly if for example you
have multiple versions of R and would like to update all of them, then
the batch file could go through systemattically).  If you care, you
can redirect stderror and stdout from the batch file to any file you
choose.

3) With appropriate privileges run (untested):

  schtasks /Create /SC DAILY /TN Rupdate /TR c:/path/to/Rupdate.bat /ST 19:00

which would create a task Rupdate that would run daily at 19:00 and
execute Rupdate.bat.

Cheers,

Josh

On Thu, May 17, 2012 at 10:28 AM, Paul Johnson <pauljohn32 at gmail.com> wrote:
> This is a basic Windows system administrator problem, asked by a Linux
> guy who is helping out in a Windows lab.
>
> I want to keep R packages up to date on MS Windows 7 with a job in the
> "Task Scheduler".  I have an R program that I can run (as
> administrator) that updates the existing packages and then installs
> all the new ones.
>
> I do not understand how to run that in a dependable way in the scheduler.
>
> If I put the update script "R-update.R" in, for example, in
>
> C:\Program Files\R\R-update.R
>
> Then what?  Do I need a CMD batch script to run the R script?
>
> I can't tell where Windows wants to write the standard output and
> error for my R job.
>
> And while I'm asking, does Windows care if I run
>
> R CMD BATCH C:\Program Files\R\R-update.R
>
> or
>
> R --vanilla -f C:\Program Files\R\R-update.R
>
> pj
> --
> Paul E. Johnson
> Professor, Political Science    Assoc. Director
> 1541 Lilac Lane, Room 504     Center for Research Methods
> University of Kansas               University of Kansas
> http://pj.freefaculty.org            http://quant.ku.edu
>
> ______________________________________________
> 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.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/



More information about the R-help mailing list