Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k4kratik/4cbb5c09ef5e1ea089b4efb76b222f6c to your computer and use it in GitHub Desktop.
Save k4kratik/4cbb5c09ef5e1ea089b4efb76b222f6c to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta
def deletion_time(ttl):
print("[DEBUG] The Current Time is: ",datetime.now())
delete_at_time = datetime.now() + timedelta(minutes=int(ttl))
print("[DEBUG] This Will be deleted at: ",delete_at_time)
hh = delete_at_time.hour
mm = delete_at_time.minute
yyyy = delete_at_time.year
month = delete_at_time.month
dd = delete_at_time.day
# minutes hours day month day-of-week year
cron_exp = "cron({} {} {} {} ? {})".format(mm, hh, dd, month, yyyy)
return cron_exp
# TTL is in minutes
calculated_expression = deletion_time(60)
print("The Calculated Cron Expression is: ",calculated_expression)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment