Logging of random and/or unexpected reboots

Hello, just wanting to confirm whether or not the routers and/or gateway devices have the ability to log a specific event whenever the device boots and it wasn’t the result of a user-initiated, scheduled, and/or automatic (eg. ping loss, jumper/relay condition, etc.) reboot.

I’ve looked through the configuration on RUT240 and cannot find this. That said, I did find a forum post related to random reboots and a suggestion to turn on debug logging, however I believe that debug logging may impact system performance which isn’t desirable. Instead, I envision some kind of boolean variable that’s set to true before the system performs an intentional or expected shutdown, and then once the system has booted some logic checks this variable and if it’s true then it just resets the variable to false, and if it’s already false then it logs an event like “Device has booted following an unexpected shutdown”.

This would be very helpful in troubleshooting network/internet outages resulting from power events and/or system stability. It would be even better if it were possible to configure an email notification for the same.

Thank you.


Please, access the WebUI and navigate to Status → Logs → Event Log → System events tab. There, you can see event type ‘reboot’ and the ‘event’ itself that shows the reason:

Kind Regards,

Hello @AndzejJ, thank you for the reply and direction with this. I don’t believe this is working reliably as I’ve disconnected the power many times from the device over the past week or two for various reasons and it’s only recorded two power events with the description “Other” and that was on the first day I setup the device…

Here are my log settings:

Again it’s RUT240 running the latest firmware.

Thank you.


First of all, I would suggest saving logs to RAM instead of flash, unless you are doing some troubleshooting. Constantly saving logs to flash will reduce the lifetime of your flash memory.

Secondly, the event logs will not show an event if you simply disconnect the power. The logs will show reboots that were called by some service.

However, you can try implementing your solution with some scripting. Following your logic, here’s what you can do:

# create a separate file with a variable value, like you mentioned
echo "1" > /etc/boot

Edit reboot command:

vi /sbin/reboot

Press ‘i’ to start editing. Use arrow keys to navigate.
Add the following at the very beginning of the script:

echo "0" > /etc/boot

Press ‘ESC’ and type ‘:wq!’ to save and quit.

Create a script:

vi /etc/bootscript.sh

For example, add the following script (you can change the logic):


if [ -e "$boot_file" ]; then
    # Read the current value from /etc/boot
    boot_value=$(cat "$boot_file")

    # Check if the current value is '1'
    if [ "$boot_value" = "1" ]; then
        # Log "unexpected reboot" with timestamp to /etc/rebootlog
        timestamp=$(date +"%Y-%m-%d %T")
        echo "[$timestamp] unexpected reboot" >> "$rebootlog_file"
    elif [ "$boot_value" = "0" ]; then
        # Change the value in /etc/boot to '1'
        echo "1" > "$boot_file"
        echo "Invalid value in $boot_file"
    echo "File $boot_file not found"

Add execution rights to the script:

chmod +x /etc/bootscript.sh

Finally, add the script to System → Custom Scripts to be executed after each reboot. The script will check the value and log into /etc/rebootlog file if the value was not changed by reboot command:

sleep 10
sh /etc/bootscript.sh &
sleep 5
#you can also pipe it into the logger so that you can see it with 'logread' command
cat /etc/rebootlog | logger
exit 0

To check /etc/rebootlog, execute:

cat /etc/rebootlog

Kind Regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.