Script to Reboot Routerboard

I am trying to write a script to reboot one of my routers daily at midnight. I have never even looked at the scripting feature before today. Everything I am reading in the manual shows complicated scriptng but nothing on something as smple as a scheduled reboot. Can anyone help me out with this little script.

Thanks

To reboot the unit all you have to type is:
/system reboot

Just save a script with that command in it. Then schedule.

But /system reboot , ask for a confirmation yes|no

How you send the response to the script ?

-Roddy

if you run it in script, it won’t ask anything

There is a scheduler task for rebooting MT every 8 hours:

/system scheduler
add comment="Reboot every 8 hours" disabled=no interval=8h name=Reboot8 on-event=\
    "/system reboot" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive \
    start-date=jul/16/2010 start-time=08:00:00

Is it correct?
“Run Count” column in WinBox=>System=>Scheduler window contains “0”.
How to check MT uptime?
How to log reboot events?



:put [/system resource get uptime];

reboot one of my routers daily at midnight

Can I ask why ?

They should not need rebooting.
In Linux world, a reboot required = something broken, which should, and can be fixed.

Yep, this is wonderful idea, but in real life our wifi channel hangs up every day
and the only workaround solution found at now is to reboot AP periodically.

why does it hang up? it’s not normal!

Yep, this is wonderful idea, but in real life our wifi channel hangs up every day

no, in real life, wifi channels don’t hang up. you have a problem

Great. What to check at next hangup for diagnose? :unamused:

make sure you have latest RouterOS version, and have enabled wireless debug logs (http://wiki.mikrotik.com/wiki/Manual:Wireless_Debug_Logs) when hangup happens, make supout.rif file as soon as possible (you can even make a script that does this after reboot) and send to support.

Reboot is Microsoft.

Bad Software basically that doesn’t handle Memory well (normal reason).

Linux isn’t Microsoft.

Hang-up can be Fixed, and generally is fixed when the fault is found.

Without any data about why it Hung Up, the programmer has no where to look.

No data = no Programmer = no Fix.

We can all moan about how a Vendor can issue Firmware that doesn’t work properly (i.e. all the time), but this is the world we live in (again Thanks M$).

If you could please follow the supout instructions, then maybe you will never have to reboot again.

Rather than meat cleaver approach of rebooting every 8 hours whether router needs it or not, have you tried using /system watchdog to detect when your wifi channel hangs and rebooting THEN (with supout)? Or even disabling, delaying a few seconds, and re-enabling your wifi interface, which is less disruptive than rebooting the entire router? Also would beat waiting 1-7 hours to get channel back.

My 2011UiAS running 6.47 locks up its IPSEC tunnel and SIP-Trunk connection every week or so.
It’s paired with another Mikrotik one for IPSEC, which is on 6.33.

I plan to upgrade the 6.33 one to 6.47 tonight, but want to schedule a midnight reboot to cure the lockups, because they are really hurting me.
How do I schedule a reboot (I can write the script /system reboot) but how do I find it in the scheduler GUI once I’ve written it in the ‘script’ GUI?
(I’m a whole-site support guy so I don’t live in router command-line world.

You don’t need a script. Simply write in scheduler field ‘On Event’ /system reboot

^^^ THIS
here’s a visual
System>Scheduler>press the Blue Plus Sign

this one is set to reboot automatically everyday at 4AM

Adding reboot does just remove symptoms of a problem. Fix the problem. Upgrade to a good version.