Is this the correct way to set up a once daily cron job? #521
-
Hi River community, I am in need of a cron job on my river queue that runs once daily. I do not want it to be affected by deploys (my worry is that since the following code is in main, a new cron job gets added every time I deploy the server, instead of just running regardless).
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@assembly-winston Try combining periodic jobs with unique jobs. Use a unique interval of 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 the program started) and start running. |
Beta Was this translation helpful? Give feedback.
@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…