Please don't set the crontab to run right at midnight--some other time, or better yet with a random delay, would be a better plan. Thousands, or millions, of clients hitting the CA right at midnight causes capacity issues.
If I read your loop correctly, it would add the following lines into your crontab:
That would make all three (try to) run at the exact same time.
[in addition to all the other clients that incorrectly run at midnight]
Can your acme-client run multiple concurrently instances?
If not, then each line must ensure that it doesn't overlap [timewise] with any other running instance.
for domain in $list; do
if acme-client -v $domain; then
# Random time intervals
echo "30~45 * * * acme-client $domain && rcctl reload relayd" | crontab -
What do you guys think?
An anti-overlap feature would indeed be nice. Please let me know if y'all find one
You should have one script that iterates thru your domains and issues / updates certs as needed. It should not create cron tasks for each domain.
Instead, have one crontab that runs that script at a random time.
As you have it, multiple cron entries (one for each domain) may create overlapped executions due to various timing lags and unlucky random times. It's not clear whether your acme client supports that but I think it will be easier to manage as a single crontab anyway.
@MikeMcQ, although I completely agree with you...
The question was more of:
"What do you think of this (mess I've made) thus far ..."
"How can this best be redesigned to ensure things go correctly ..."
But, as always, you go above and beyond the call of duty!!!
You get a star: