Skip to content

Is this the correct way to set up a once daily cron job? #521

Answered by brandur
assembly-winston asked this question in Q&A
Discussion options

You must be logged in to vote

@assembly-winston Try combining periodic jobs with unique jobs.

Use a unique interval of 24 * time.Hour, and then have it be inserted periodically to make sure a copy of the job is always inserted.

Notably, don't use a periodic interval of 24 hours because if you did that, your daily job might be inserted considerably late in the day if the start time of the current leader is staggered considerably from midnight. I'd probably inserted the unique job once a minute or once every five minutes, depending on how critical it is that it starts in a very timely manner. That way, on any day rollover a new unique job will be inserted at roughly 12:00 to 12:01 or 12:00 to 12:05 (depending on when th…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@assembly-winston
Comment options

@bgentry
Comment options

@assembly-winston
Comment options

Answer selected by assembly-winston
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants