Auto Update RouterOS Package From Script - MikroTik Script RouterOS
If you administer only a few MikroTik devices, you can manually update them one by one using the WinBox tool. This is a very easy task if you install only the long-term versions. That version is rarely updated and contains only the major bug fixes.
In case that you have larger number of devices under your control, you will probably want more automation. The good news is that you can use the magic of the command line to perform such task. This means that you can also write the update script.
Contrary to the scenario with your local update source point, if your routers are independent to each other and on the separate Internet links, you will want to use the different process to update them all at once.
# Simple RouterOS upgrade script
# version 1 (09.03.2020)
# written by Srdjan Stanisic
# go to the update context
/system package update
# set the channel
set channel=long-term
# check for updates
check-for-updates
# we can log the status
:log info "$[get status]"
#
# check for the new version
# if there is a newer version, then download it and reboot the router
# you can omit automatic reboot and send email instead
# additionally, we can omit the ELSE part
#
:if (installed-version != latest-version) do={
download;
} else={
:put "System is already up to date"
}
This script is ready to be used. Copy it into the text file and save it with .rsc extension
CREDIT: https://mivilisnet.wordpress.com/2020/03/31/updating-mikrotik-router-from-the-command-line/