Make cron run twice a day, randomly

Run cron twice a day to make sure certificates are guaranteed to be renewed
at least once during the last 24 hours of the certificate lifetime.
This commit is contained in:
Marcel Waldvogel 2017-07-16 20:43:41 +02:00
parent cae6c8e5f5
commit 12ee24eedc

16
acme.sh
View File

@ -4420,17 +4420,17 @@ installcronjob() {
fi
_t=$(_time)
random_minute=$(_math $_t % 60)
random_hour1=$(_math $_t / 60 % 12)
random_hour2=$(_math $random_hour1 + 12)
if _exists uname && uname -a | grep SunOS >/dev/null; then
crontab -l | {
cat
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
} | crontab --
ct_stdin=--
else
crontab -l | {
cat
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
} | crontab -
ct_stdin=-
fi
crontab -l | {
cat
echo "$random_minute $random_hour1,$random_hour2 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
} | crontab $ct_stdin
fi
if [ "$?" != "0" ]; then
_err "Install cron job failed. You need to manually renew your certs."