Schedule Reboot

Is there a easy way to schedule a reboot to occur at 3am and only happen once. This is to do a OS update.

Due to the [Y/N] prompt that RouterOS gives when trying to reboot from the command line, I had to add a “/system reboot” task to system scheduler (as disabled), then another script to enable the task, then finally schedule that script that enabled the original task.

e.g.

/system scheduler
add disabled=yes interval=1s name=reboot-mt-on-demand on-event="/system scheduler disable reboot-mt-on-demand;\r\
    \n/system reboot;" policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/1970 start-time=19:06:31
/system script
add name=reboot-mt-on-demand owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=\
    "/system scheduler enable reboot-mt-on-demand"

Then just schedule the “reboot-mt-on-demand” script to run at 3am. Hope this makes sense

I Believe you only wish to reboot the device on days that RouterOS upgrades have been done? Do you manually do the upgrades on each device or do you have a way to do them all remotely but just need a reboot on those days?

There is a few ways you can go about this and one way is to use netwatch to trigger events remotely.

You would then set up each device with the following script. upgrade.rsc will have all the information you need to upgrade your router. If your interested in this method let me know and ill get the code together for it and send it through.

/system script
add name=rscfetch policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source={
{/file ;:if ([find name="upgrade.rsc"]!="") do={remove [find name="upgrade.rsc"]}}
:global ftpserver
:global usrnme
:global passwd
:global pckgname
:set pckgname ("upgrade.rsc")
:set ftpserver "10.10.10.1"
:set usrnme "FTPupg"
:set passwd "FTPupg123"

:if ([:len [/file find name="upgrade.rsc"]] = 0) do={
:log error "Downloading Upgrade File - $pckgname";/tool fetch address="$ftpserver" src-path="$pckgname" user="$usrnme" password="$passwd" mode=ftp;/import file=upgrade.rsc} else={
:log error "Upgrade File in Limbo";/tool e-mail send to="someone@someone.com" subject=([/system identity get name] . " RSC File Import Error")}
}

/tool netwatch add disabled=no down-script="" host=10.2.1.1 interval=1m timeout=1s up-script=rscfetch;

*This script was mostly taken from an older post and just changed with latest syntax and tweaked. But the original isn’t mine. Can’t remember which post it came from however.

The following will disable itself and reboot your router at 3am.


/system scheduler add name=reboot start-time=03:00:00 on-event=“{/system scheduler set [find name=reboot] disabled=yes;\n
:execute script="/system reboot";}”

re-enable as needed.
Tested on v7.11.2

For sure everyone was waiting for your response 6 years later…


Do you make a necropost and even write the script badly?