Home  >  Article  >  Operation and Maintenance  >  How to check if the system has restarted in linux

How to check if the system has restarted in linux

王林
王林Original
2020-03-12 16:40:3811461browse

How to check if the system has restarted in linux

You can further determine whether the system has been restarted by querying the last time the system was restarted.

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 displays the system running time in the past few days.

last was originally designed to display the login history of a specific user. In Linux, there is a special "pseudo-user" called reboot that automatically logs in immediately when the system restarts. In this way, by checking the login history of the reboot user, you can check the last reboot time.

(Recommended tutorial: linux tutorial)

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 startup time of the system. The uptime command will display the current time and also the time the system has been running. From this information, you can calculate the last time the system booted.

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

Related video tutorial recommendations: linux video tutorial

The above is the detailed content of How to check if the system has restarted in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn