For engineers in the Linux platform development or operations, often need to query the system last restart time, this article will give you three ways to introduce:
Method one: Last command
# last Reboot
Reboot system boot 2.6.32-431.el6.i Wed Jul 30 13:44-21:39 (46+07:55)
Reboot system boot 2.6.32-431.el6.i Sun Apr 13 14:28-09:27 (107+18:59)
Reboot system boot 2.6.32-431.el6.i Tue Mar 25 22:27-14:19 (18+15:52)
This command actually shows the operating time of the system in the last few days. Last was originally designed to show the login history of a particular user. In Linux, there is a special "pseudo-user" called Reboot that will automatically log in as soon as the system restarts. This allows you to check the last restart time by checking the login history of the reboot user.
Method Two: Who-b
Use the WHO command with ‘-b ' option.
# Who-bsystem Boot Jul 30 13:44
Method Three: Uptime command
You can also use the uptime command to infer the last boot time of the system. The uptime command displays the current time and also shows how long the system has been running. From this information, you can calculate the last time the system was started.
# uptime21:46:31 up, 8:02, 1 user, load average:0.04, 0.05, 0.01
- This article is from: Linux Tutorial Network
Three ways to query the last restart time of a Linux system