Send Email About Reboot - MikroTik Script RouterOS

This script is meant for being run on router startup (using scheduler). Script sends an email with time of router reboot and entire log once 90 seconds have been passed since initial time synchronization from NTP. Besides event about reboot is logged once time has been synchronized from NTP.

:while ( [/system ntp client get status]!="synchronized" ) do={ :delay 10s }
:delay 10s
/log info "time updated; uptime: $[/system resource get uptime]"
:local es "$[/system identity get name] rebooted on $[/system clock get date] $[/system clock get time] uptime $[/system resource get uptime]"
:delay 90s
:local eb "Log contents (with 90 seconds delay):\r"
:foreach le in=[/log print as-value] do={
  :set eb ($eb.[:tostr [($le->"time")]]." ".[:tostr [($le->"topics")]].": ".[:tostr [($le->"message")]]."\r")
}
/tool e-mail send to="[email protected]" subject=$es body=$eb
This script helps to keep track of router reboots (e.g. of reboots caused by power interruptions).

This script requires NTP package (from All packages download).

NB Script has not been tested with logging to disk enabled. In case time synchronization is not available after reboot, the script will send e-mail once the time is synchronized (date and time in subject will be from the moment of time synchronization and not from the moment of reboot).