From 8fe33da85d3e15d379bbf61e91f5f934d6263f24 Mon Sep 17 00:00:00 2001 From: clonejo Date: Sun, 3 May 2020 16:34:42 +0200 Subject: [PATCH] Run nightly tasks on a random minute after 03:00 to avoid overload (#1754) - The MIAB version check regularly fails at 03:00, presumably because a large portion of installations is checking mailinabox.email at the same time. - At installation time, the time of the nightly clock is configured to run at a random minute after 03:00, but before 04:00. - Users might expect the nightly tasks to be over at a certain time and run their own custom tasks afterwards. This could thus interfere with custom backup routines. - This breaks reproducibility of the installation process. - Users might also be surprised by the nightly task time changing after updating MIAB. --- CHANGELOG.md | 1 + setup/management.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c723f3b5..2f28474c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Software updates: System: +* Nightly backups now occur on a random minute in the 3am hour (in the system time zone). The minute is chosen during Mail-in-a-Box installation/upgrade and remains the same until the next upgrade. * Fix for mail log statistics report on leap days. * Fix Mozilla autoconfig useGlobalPreferredServer setting. diff --git a/setup/management.sh b/setup/management.sh index 3caf8eea..9d7c762c 100755 --- a/setup/management.sh +++ b/setup/management.sh @@ -101,10 +101,11 @@ hide_output systemctl enable mailinabox.service # Perform nightly tasks at 3am in system time: take a backup, run # status checks and email the administrator any changes. +minute=$((RANDOM % 60)) # avoid overloading mailinabox.email cat > /etc/cron.d/mailinabox-nightly << EOF; # Mail-in-a-Box --- Do not edit / will be overwritten on update. # Run nightly tasks: backup, status checks. -0 3 * * * root (cd `pwd` && management/daily_tasks.sh) +$minute 3 * * * root (cd `pwd` && management/daily_tasks.sh) EOF # Start the management server.