import os,time enough=False while not enough: print "checking disk space" statvfs = os.statvfs('/var/tmp') free=statvfs.f_bavail*statvfs.f_frsize free/=1024**3 if free>5: print "there is enough space left on /var/tmp ({0}Gb)".format(free) enough=True else: print "waiting for diskspace ({0}Gb)".format(free) time.sleep(5)