Skip to content

Add a configurable cron interval#6971

Open
e-nomem wants to merge 20 commits into
acmesh-official:devfrom
e-nomem:configurable-cron-interval
Open

Add a configurable cron interval#6971
e-nomem wants to merge 20 commits into
acmesh-official:devfrom
e-nomem:configurable-cron-interval

Conversation

@e-nomem

@e-nomem e-nomem commented May 17, 2026

Copy link
Copy Markdown

This PR is an implementation of my idea from #6965 (comment) and pulls both #6939 and #6953 as they currently are and adds a --cron-interval CLI flag. This should let the cron job figure out if the next cron run will happen before the ARI renewal window ends and trigger an early renewal as necessary. It ensures that we will never overshoot the 30 minute renewal window for the shortlived profile while also not renewing immediately after the 7 day renewal window opens for the classic profile.

Since this PR effectively contains 3 separate PRs in it, here's a link to just my changes without the other two: 3b1f3c8...e-nomem:acme.sh:configurable-cron-interval

sim0n-v added 9 commits May 6, 2026 22:27
With ACME Renewal Info (RFC9773 §4.3), fetching renewal window should be more frequent, e.g. in case of revocation incident.
"For instance, a server that needs to revoke certificates within 24 hours of notification of a problem might choose to reserve twelve hours for investigation, six hours for clients to fetch updated RenewalInfo objects, and six hours for clients to perform a renewal."

More flexible option is to run the cron job every hour and only refresh ARI when the last one + Retry-After header is in the past.
@e-nomem

e-nomem commented May 17, 2026

Copy link
Copy Markdown
Author

@sim0n-v this contains both your PRs

Comment thread acme.sh
Comment thread acme.sh Outdated
Comment thread acme.sh Outdated
Comment thread acme.sh Outdated
Comment thread acme.sh Outdated
$_CRONTAB -l 2>/dev/null | {
cat
echo "$random_minute $random_hour * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
echo "$random_minute $random_hour/$_cron_interval * * * $lesh --cron $_c_entry> /dev/null"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried $random_hour/6 in 647c733 but didn't work. Don't really know why...

That's why I came up with a list of hours instead ($random_hour,$random_hour+$_cron_interval*1,$random_hour+$_cron_interval*2 etc. until $random_hour+$_cron_interval*(24 / $_cron_interval)).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because $random_hour/$_cron_interval is technically non-standard syntax. The left side is supposed to be a range expression so we probably want ${random_hour}-23/$_cron_interval

@e-nomem e-nomem force-pushed the configurable-cron-interval branch from e1c62b5 to 00b686c Compare May 17, 2026 23:31
@e-nomem e-nomem force-pushed the configurable-cron-interval branch from d0d63d0 to 09bda1e Compare May 18, 2026 02:49
Comment thread acme.sh
--cron-interval <interval hours> Sets the cron interval when installing the cron job or used by the renew commands to detect if
early cert renewal is required when using ARI. Only valid for '--install', '--install-cronjob',
'--renew', '--renew-all', and '--cron'.
See: $_ARI_WIKI

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this with the assumption that the Wiki will be updated to clarify the interaction between this flag and the ARI feature if this PR is merged.

Comment thread acme.sh
_debug "_server" "$_server"

_cron_interval="$3"
debug "_cron_interval" "$_cron_interval"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: should be _debug

Comment thread acme.sh

_isEcc="$2"
_renewServer="$3"
_cron_interval="$4"

@sim0n-v sim0n-v May 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that upgrading acme.sh will update the cronjob as well. This value might be not set.
ARI is enabled by default so maybe add something like:

if [ -z "$_cron_interval" ]; then
  _cron_interval=24
fi

Comment thread acme.sh
Comment on lines +1867 to +1868
_offset_sec="$(_math "$1" * 3600)"
_now_unix="$(_math "$_now_unix" + "$_offset_sec")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get some errors with these (running bash and sh): I think * and + should be escaped.

The first line (with *) prints the current dir.
The second line (with + ) cannot understand the symbol.

Fixed with escaped char.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants