Small script to re-create a file indefinitely
Unless you really want to reinvent the wheel, you could use FileUtils.touch for this:


  FileUtils.touch
  
  Updates modification time (mtime) and access time (atime) of file(s) in list. Files are created if they don’t exist.


For example:

require 'fileutils'

PATH = "C:/folder/to/file/test1.txt"
SLEEP_TIME = 30

loop do
  FileUtils.touch(PATH)
  sleep(SLEEP_TIME)
end