Three methods to query the last reboot time of the Linux system

Method 1: 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 system uptime for the last few days. last was originally designed to display the login history of a particular user. In Linux, there is a special "pseudo-user" called reboot that automatically logs in as soon as the system reboots. This way by checking the login history of the reboot user, you can check the last reboot time.

Method 2: who -b

Use the who command with the '-b' option.

# who -b
system boot Jul 30 13:44

Method 3: uptime command
You can also use the uptime command to infer the last boot time of the system. The uptime command will display the current time, as well as the time the system has been running. From this information, you can calculate when the system was last booted

# uptime
21:46:31 up 46 days, 8:02, 1 user, load average: 0.04, 0.05, 0.01

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325345573&siteId=291194637