Created
May 30, 2021 09:22
-
-
Save k4kratik/4cbb5c09ef5e1ea089b4efb76b222f6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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