Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for file to exist

Tags:

r

Is there a way in R to pause execution of a script until a file is created? I would like to pre-load R in advance to decrease the execution time when the input file is generated.

like image 735
John Richardson Avatar asked Dec 11 '13 23:12

John Richardson


1 Answers

If you want to keep this in R, you might try the following code:

while (!file.exists(your.file.name)) {
  Sys.sleep(1)
}

A shorter sleep duration would poll more frequently but might be slightly more CPU intensive.

like image 76
josliber Avatar answered Oct 06 '22 18:10

josliber