Skip to content

Commit 0c8870c

Browse files
authored
Merge pull request #944 from MarcelWaldvogel/random-cron
Random cron
2 parents 1a90f66 + 92dbe6c commit 0c8870c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

acme.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5993,6 +5993,7 @@ installcronjob() {
59935993
fi
59945994
_t=$(_time)
59955995
random_minute=$(_math $_t % 60)
5996+
random_hour=$(_math $_t / 60 % 24)
59965997

59975998
if ! _exists "$_CRONTAB" && _exists "fcrontab"; then
59985999
_CRONTAB="fcrontab"
@@ -6017,16 +6018,14 @@ installcronjob() {
60176018
_info "Installing cron job"
60186019
if ! $_CRONTAB -l | grep "$PROJECT_ENTRY --cron"; then
60196020
if _exists uname && uname -a | grep SunOS >/dev/null; then
6020-
$_CRONTAB -l | {
6021-
cat
6022-
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
6023-
} | $_CRONTAB --
6021+
_CRONTAB_STDIN="$_CRONTAB --"
60246022
else
6025-
$_CRONTAB -l | {
6026-
cat
6027-
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
6028-
} | $_CRONTAB -
6023+
_CRONTAB_STDIN="$_CRONTAB -"
60296024
fi
6025+
$_CRONTAB -l | {
6026+
cat
6027+
echo "$random_minute $random_hour * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
6028+
} | $_CRONTAB_STDIN
60306029
fi
60316030
if [ "$?" != "0" ]; then
60326031
_err "Install cron job failed. You need to manually renew your certs."

0 commit comments

Comments
 (0)