For polling, the simplest solution is time.sleep(n)
which sleeps for n
seconds. Your code would look something like this, then:
import time.sleep as sleep
import sys
try:
while True:
# code to find the latest file
# code to copy it to another location
sleep(3600)
except KeyboardInterrupt:
print("Quitting the program.")
except:
print("Unexpected error: "+sys.exc_info()[0])
raise
(Because this loop can run forever, you should definitely wrap it in a try
/except
block to catch keyboard interrupts and other errors.) Cron jobs are a perfectly good option if you're only going to be on *nix platforms, of course, but this provides platform independence.