#!/usr/bin/env python import time file="/var/db/connect.gone" maxage=0.25 now=time.time() max=int(now)-(maxage*86400) new=[] f = open(file, 'r') for line in f.readlines(): start = int(line.split()[1]) if start > max: new.append(line) f.close() f = open(file, 'w') for line in new: f.write(line) f.close()