Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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