Checking the system reboot history is an important task for system administrators in Linux. Knowing when the system was last rebooted can help in troubleshooting issues and planning for maintenance tasks. One of the ways to check system reboot history in Linux is by using the last command.

Advertisement

The last command displays a list of all system logins and logouts, including system reboots. By default, the last command displays the information in reverse chronological order, with the most recent events at the top of the output.

Check Last Reboot History

Mostly Linux/Unix systems provide the last command, which provides us the history of last logins and system reboots. These entries are keeps in the lastlog file. Run the last reboot command from the terminal, and you will get the details of the last reboots.

last reboot 
Output
reboot system boot 5.4.0-80-generic Tue Feb 22 12:50 still running reboot system boot 5.4.0-80-generic Tue Feb 22 11:20 - 12:50 (01:30) reboot system boot 5.4.0-80-generic Mon Feb 21 14:32 - 11:20 (20:48)

The output shows the date and time of each system reboot, along with the system message indicating the reason for the reboot. In the example above, the system was last rebooted on February 22nd at 12:50 and is still running.

Customize the Output

You can customize the output of the last command by using various options. For example, you can use the -n option to specify the number of lines to display, or the -F option to display the full date and time in the output.

Here are some examples:

last reboot -n 5    # Displays the last 5 system reboots
last reboot -F       # Displays the full date and time in the output

Check System Uptime

Additionally, you can also use the uptime command to find the system uptime from last booted. Just open the terminal on your system and type uptime and hit enter.

uptime  
Output
11:56:48 up 65 days, 5:42, 1 user, load average: 0.09, 0.11, 0.18

As per above output, the system is running from 65 days, 5 hours and 42 minutes.

Conclusion

Checking system reboot history in Linux is an essential task for system administrators. The last command provides an easy way to check system reboot history by displaying a list of all system reboots in reverse chronological order. By interpreting the output of the last command, you can get a better understanding of your system’s uptime and availability.

Share.

2 Comments

  1. this command isn’t working, I know that a server is restarted. but it is not showing up
    The output is

    wtmp begins Sun Jul 28 03:26:39 2019

Leave A Reply


Exit mobile version