From 64e53a7d32106e334cedeab48e5d9fc4499cd9f0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 31 Jan 2024 17:52:48 +0100 Subject: packages-update: schedule reboot at pre-calculated time --- doc/packages-update.md | 5 ++++- packages-update.rsc | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/packages-update.md b/doc/packages-update.md index 280c420..b3acf89 100644 --- a/doc/packages-update.md +++ b/doc/packages-update.md @@ -40,7 +40,10 @@ Configuration The configuration goes to `global-config-overlay`, this is the only parameter: * `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM - and 4 AM) + and 5 AM) + +By modifying the scheduler's `start-time` you can force the reboot at +different time. > ℹ️ **Info**: Copy relevant configuration from > [`global-config`](../global-config.rsc) (the one without `-overlay`) to diff --git a/packages-update.rsc b/packages-update.rsc index 8b7d617..863d273 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -23,19 +23,19 @@ :global PackagesUpdateDeferReboot; :local Schedule do={ + :global GetRandomNumber; :global LogPrintExit2; :global RebootForUpdate do={ - :global RandomDelay; - $RandomDelay 3600; /system/reboot; } - /system/scheduler/add name="_RebootForUpdate" start-time=03:00:00 interval=1d \ + :local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ]; + /system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=1d \ on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \ ":global RebootForUpdate; \$RebootForUpdate;"); - $LogPrintExit2 info $1 ("Scheduled reboot for update between 3 AM and 4 AM local time (" . \ - [ /system/clock/get time-zone-name ] . ").") true; + $LogPrintExit2 info $1 ("Scheduled reboot for update at " . $StartTime . \ + " local time (" . [ /system/clock/get time-zone-name ] . ").") true; } $ScriptLock $0; -- cgit v1.2.3-70-g09d2