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

How to check if the system has restarted in linux

王林
Release: 2020-03-12 16:41:27
Original
11549 people have browsed it

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)
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template