Hi, I was wondering if there is there a way you can schedule an R script to run automatically through a scheduled task in windows or similar?.. Would R have to be open on the user's PC or could it be closed providing we pointed it correctly at R?... Thank you Alex Alex Johnson Operational Research Analyst The AA 01256 492133 / Ext 622133 Automobile Association Developments Limited. Registered office: Fanum House, Basing View, Basingstoke, RG21 4EA. Registered in England and Wales Number: 01878835 "To our Members we're the 4th Emergency Service" This electronic message contains information from The Au...{{dropped:17}}
if you want to use R itself, you could try -- # check your time zone's abbreviation Sys.time() # subtract the time you want the program to run from the current time, # including your time zone..mine is EDT Sys.sleep( as.POSIXct( "2013-10-11 06:30:00 EDT" ) - Sys.time() ) -- at the very top of your script and just run the whole thing. it will unsleep at the exact time specified. if you use some other timer to run a command at a certain time, then that command probably should call Rscript.exe-- "C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" "C:\my directory\my script.R" or, if R's executables are in your PATH, it could just be Rscript "C:\my directory\your script.R" On Fri, Oct 11, 2013 at 4:04 AM, Johnson, Alex <Alex.Johnson@theaa.com>wrote:> Hi, > > > > I was wondering if there is there a way you can schedule an R script to > run automatically through a scheduled task in windows or similar?.. > > Would R have to be open on the user's PC or could it be closed providing > we pointed it correctly at R?... > > > Thank you > > > > Alex > > > > Alex Johnson > > Operational Research Analyst > > The AA > > 01256 492133 / Ext 622133 > > > > Automobile Association Developments Limited. Registered office: Fanum > House, Basing View, Basingstoke, RG21 4EA. Registered in England and > Wales Number: 01878835 > > > > "To our Members we're the 4th Emergency Service" > This electronic message contains information from The Au...{{dropped:17}} > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Steps: 1. write your code in R command line format 2. save to a .sh file 3. Add to cron of linux machine Regards, Vivek -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Johnson, Alex Sent: Friday, October 11, 2013 4:05 PM To: r-help at r-project.org Subject: [R] automation of an R script to run Hi, I was wondering if there is there a way you can schedule an R script to run automatically through a scheduled task in windows or similar?.. Would R have to be open on the user's PC or could it be closed providing we pointed it correctly at R?... Thank you Alex Alex Johnson Operational Research Analyst The AA 01256 492133 / Ext 622133 Automobile Association Developments Limited. Registered office: Fanum House, Basing View, Basingstoke, RG21 4EA. Registered in England and Wales Number: 01878835 "To our Members we're the 4th Emergency Service" This electronic message contains information from The Au...{{dropped:8}}
Look at the ?Startup help page in R. It shows a couple of ways to have code run automatically when R starts (and can depend on which folder R starts from). So you could have the windows task scheduler run R and use the above to set the script to run. Also look at ?Rscript for a way to run a script in batch mode, you can schedule a run of Rscript on a specific script file. Within R there is the tclTaskSchedule function in the tcltk2 package. If you leave R running then that function can set some code to run at a given time, or at a regular interval. On Fri, Oct 11, 2013 at 2:04 AM, Johnson, Alex <Alex.Johnson@theaa.com>wrote:> Hi, > > > > I was wondering if there is there a way you can schedule an R script to > run automatically through a scheduled task in windows or similar?.. > > Would R have to be open on the user's PC or could it be closed providing > we pointed it correctly at R?... > > > Thank you > > > > Alex > > > > Alex Johnson > > Operational Research Analyst > > The AA > > 01256 492133 / Ext 622133 > > > > Automobile Association Developments Limited. Registered office: Fanum > House, Basing View, Basingstoke, RG21 4EA. Registered in England and > Wales Number: 01878835 > > > > "To our Members we're the 4th Emergency Service" > This electronic message contains information from The ...{{dropped:19}}