Update after....two days

I use a simple scheduled script to update my RB :

/system package update
check-for-updates once
:if ( [get status] = "New version is available") do={ 
install
etc etc

How can I delay the update after i.e. two days the new version has been detected ?

I.e. making the script to collect current date and create a schedule to run update to next two days…
Very poor knowledge in scripting… :frowning:
Any suggestion really appreciated

Use Scheduler to schedule when your script runs.

https://lmgtfy.com/?q=mikrotik+script+schedule

…I could set a daily “schedule1” to check if new version is availale, if yes, enable “schedule2” with interval 2days ,who launches update script.
This script also disables “schedule2” itself, stopping updates unless “schedule1” finds a new version available.

Surely there would a better and elegant way, but no skill here…

https://wiki.mikrotik.com/wiki/Manual:Scripting

look for global variables

Make sure schedule1 disables itself when scheduling schedule2, or else schedule2 will just get kicked two days down the road every day. Schedule2 also has to re-enable schedule1 when it runs.

Global variables work OK as long as you don’t perform reboots (or have them performed to you).

How about this?

# check for updates, install after two days

:if ([ / system scheduler print count-only where name="reboot-for-update" ] > 0) do={
  :error "A reboot for update is already scheduled.";
}

/ system package update check-for-updates without-paging;
:local Update [ / system package update get ];

:if ($Update->"installed-version" != $Update->"latest-version") do={
  / system scheduler add name="reboot-for-update" interval=2d \
    on-event=("/ system scheduler remove reboot-for-update; " . \
    "/ system package update check-for-updates without-paging; " . \
    ":if ([ / system package update get latest-version ] = \"" . $Update->"latest-version" . "\") do={ / system package update install; }");
}

It checks for updates, then adds a scheduler if update is available. With scheduler in place it does early exit without further action.

The scheduler removes itself, checks for update again, then installs if the version is still the same. (If versions differ the script kicks in again.)