1

I would like to write an R script that runs for the whole day. It should basically be an infinite loop that fetches trading data, applies smart stuff to it, and uploads the trading data somewhere else again.

I'm thinking about starting the script at 8:30am, then it would automatically "do nothing" until 9:00am, then start running in a loop until 5:00pm, and then idle again, until I shut down the R session.

What's the best way to achieve this behavior?

I have no access to Linux machines, so multiple scripts and cronjobs are not possible, unfortunately.

Alexander Engelhardt
  • 1,632
  • 3
  • 16
  • 31

3 Answers3

2
 while ( as.numeric(format(Sys.time(),format =  "%H")) %in% 8:17){
if(as.numeric(format(Sys.time(),format =  "%H")) %in% 9:17){ 
# your code here
}
}
2

You can take a look at this link

Windows Task scheduler can do the task

Even with Rstudio you can Some more links here and here Link Then the package taskschedulR

Community
  • 1
  • 1
ivivek_ngs
  • 917
  • 3
  • 10
  • 28
1

If you're on a Windows consumer platform, you could use the 'scheduleR' package. Otherwise, if you're on a Windows Server, then you could use the Windows Scheduler.

WHoekstra
  • 173
  • 7