Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to run a R code at a specific time

Tags:

r

timer

triggers

I want to run a R code at a specific time that I need. And after the process finished, I want to terminate the R session.

If a code is as below,

tm<-Sys.time()
write.table(tm,file='OUT.TXT', sep='\t');
quit(save = "no")

What should I do to run this code at "2012-04-18 17:25:40". I need your help. Thanks in advance.

like image 646
TaeHeon Kim Avatar asked Apr 18 '12 07:04

TaeHeon Kim


People also ask

Can you schedule an R script to run?

In recent versions of RStudio (0.99. 893 or later), select Addins and next select 'Schedule R scripts on Windows'. This will allow you to select a script to be scheduled at your specified timepoints. The script will be copied to the Rscript repo folder and will be launched from there each time.

How do I time my code in R?

To measure execution time of R code, we can use Sys. time function. Put it before and after the code and take difference of it to get the execution time of code.

How do I run an R server?

Access the R Console To use the most recent version of R, use the module load command and then just type R. You'll see the normal startup text for an R terminal and an R command prompt instead of the server command prompt.


1 Answers

It is easiest to use the Task Scheduler of Windows, or a cron job under Linux. There you can specify a command or program that should be run at a certain time you specify.

like image 142
Paul Hiemstra Avatar answered Sep 20 '22 20:09

Paul Hiemstra