mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-25 13:24:29 +02:00
packages-update: schedule reboot at pre-calculated time
This commit is contained in:
parent
461f7b6e76
commit
64e53a7d32
2 changed files with 9 additions and 6 deletions
|
@ -40,7 +40,10 @@ Configuration
|
||||||
The configuration goes to `global-config-overlay`, this is the only parameter:
|
The configuration goes to `global-config-overlay`, this is the only parameter:
|
||||||
|
|
||||||
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
|
* `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
|
> ℹ️ **Info**: Copy relevant configuration from
|
||||||
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to
|
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
:global PackagesUpdateDeferReboot;
|
:global PackagesUpdateDeferReboot;
|
||||||
|
|
||||||
:local Schedule do={
|
:local Schedule do={
|
||||||
|
:global GetRandomNumber;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
|
|
||||||
:global RebootForUpdate do={
|
:global RebootForUpdate do={
|
||||||
:global RandomDelay;
|
|
||||||
$RandomDelay 3600;
|
|
||||||
/system/reboot;
|
/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\"; " . \
|
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||||
":global RebootForUpdate; \$RebootForUpdate;");
|
":global RebootForUpdate; \$RebootForUpdate;");
|
||||||
$LogPrintExit2 info $1 ("Scheduled reboot for update between 3 AM and 4 AM local time (" . \
|
$LogPrintExit2 info $1 ("Scheduled reboot for update at " . $StartTime . \
|
||||||
[ /system/clock/get time-zone-name ] . ").") true;
|
" local time (" . [ /system/clock/get time-zone-name ] . ").") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue