automation of an R script to run

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

automation of an R script to run

Johnson, Alex
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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: automation of an R script to run

Bart Joosen
This post has NOT been accepted by the mailing list yet.
You could write a .bat file which calls R CMD or Rscript.exe with the needed script as a parameter.
This .bat file can be used for the windows scheduler.

Bart
Reply | Threaded
Open this post in threaded view
|

Re: automation of an R script to run

ajdamico
In reply to this post by Johnson, Alex
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 <[hidden email]>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}}
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: automation of an R script to run

Vivek Singh
In reply to this post by Johnson, Alex

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: [hidden email] [mailto:[hidden email]] On
Behalf Of Johnson, Alex
Sent: Friday, October 11, 2013 4:05 PM
To: [hidden email]
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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: automation of an R script to run

glsnow
In reply to this post by Johnson, Alex
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 <[hidden email]>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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: automation of an R script to run

Johnson, Alex
Thank you everyone for your help.

I have managed to now figure it out by creating a batch file to run R. I
can then schedule this batch file to run.

Not sure if this is the best way of doing it but it seems to work for
me.

 

Thank you for the help

Alex

 

________________________________

From: Greg Snow [mailto:[hidden email]]
Sent: 11 October 2013 18:45
To: Johnson, Alex
Cc: r-help
Subject: Re: [R] automation of an R script to run



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 <[hidden email]>
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\ A...{{dropped:24}}

______________________________________________
[hidden email] 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.