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.
This commit is contained in:
clonejo 2020-05-03 16:34:42 +02:00 committed by Joshua Tauberer
parent c202a5cbc6
commit 8fe33da85d
2 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@ Software updates:
System: 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 for mail log statistics report on leap days.
* Fix Mozilla autoconfig useGlobalPreferredServer setting. * Fix Mozilla autoconfig useGlobalPreferredServer setting.

View File

@ -101,10 +101,11 @@ hide_output systemctl enable mailinabox.service
# Perform nightly tasks at 3am in system time: take a backup, run # Perform nightly tasks at 3am in system time: take a backup, run
# status checks and email the administrator any changes. # status checks and email the administrator any changes.
minute=$((RANDOM % 60)) # avoid overloading mailinabox.email
cat > /etc/cron.d/mailinabox-nightly << EOF; cat > /etc/cron.d/mailinabox-nightly << EOF;
# Mail-in-a-Box --- Do not edit / will be overwritten on update. # Mail-in-a-Box --- Do not edit / will be overwritten on update.
# Run nightly tasks: backup, status checks. # 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 EOF
# Start the management server. # Start the management server.