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
# https://unix.stackexchange.com/a/580493/68670
echo "30~45 * * * acme-client $domain && rcctl reload relayd" | crontab -
sleep 4
else
exit
fi
done
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 ..."
than
"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:
Hi! That sounds like a very good idea but first I need to get better organized.
For now I just did (OpenBSD):
for domain in $list; do
acme-client -v $domain
# Run sometime during the 1st of each month
(crontab -l; echo "~ ~ 1 * * acme-client $domain && rcctl reload relayd") | crontab -
sleep 8
done
Checking monthly is not ideal.
Even checking weekly is only 4 (or 5) tries a month - not much room for error.
You really want to check it at least once a day.