Skip to content

Instantly share code, notes, and snippets.

@pH-7
Last active July 18, 2025 13:43
Show Gist options
  • Save pH-7/0692455748f8dc0e1ab775cf0311f962 to your computer and use it in GitHub Desktop.
Save pH-7/0692455748f8dc0e1ab775cf0311f962 to your computer and use it in GitHub Desktop.
Check if file has been checked for more than 24h
import os
import time
def oneDaySinceLastCheck(timestamp_file='.touch_one_day_since_last_check'):
"""
Check whether it has been more than 24h since the last check.
"""
try:
lastCheck = os.path.getmtime(timestamp_file)
except FileNotFoundError:
lastCheck = 0
if time.time() > 24*60*60 + lastCheck:
# Update timestamp file
with open(timestamp_file, 'w') as f:
f.write(str(time.time()))
return True
return False # Default value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment