File size: 299 Bytes
1425afc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import os
import time
MAX_AGE = 60 * 60 # 1 hour
def cleanup(folder="jobs"):
now = time.time()
for f in os.listdir(folder):
path = os.path.join(folder, f)
if os.path.isfile(path):
if now - os.path.getmtime(path) > MAX_AGE:
os.remove(path) |