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 juanwolf/94840f4bd3896aa38671 to your computer and use it in GitHub Desktop.
Save juanwolf/94840f4bd3896aa38671 to your computer and use it in GitHub Desktop.
crontab = settings.CELERYBEAT_SCHEDULE['mytask']['schedule']
# We get the duration until the next execution
delta = crontab.remaining_estimate(crontab.now())
# We get the datetime of the next execution
next_exec = datetime.now() + delta
# We get the duration between two execution
duration = crontab.remaining_estimate(next_exec) - delta
# So the last run is the next_exec minus the duration between two task.
last_run = next_exec - duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment