I have one r function i want to run it automatically(scheduling) after every predefined time interval (example after every 5 mins) Is it possible if yes then how it can be done.
Ideally you should use the system scheduler for this: cron on a Unix system or Scheduled Tasks on a Windows system.
There may be some requirement that means you can't spawn a new process for each invocation of the function. If so then use an infinite loop with a call to Sys.sleep() to wait until the next invocation is due.
repeat {
startTime <- Sys.time()
runFunction()
sleepTime <- startTime + 5*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With