Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query the recent restart time of the machine in the Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to query the recent restart time of the machine in the Linux system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Use the who command to view the time / date of the system restart

You need to use the who command on the terminal to print who has logged in to the system, and the who command will also show the last time the system booted. Use the last command to view the date and time of the system restart and shutdown, run:

$who-b

Sample output:

System boot 2017-06-2017: 41

Use the last command to query the user who recently logged in to the system and the time and date of the system restart. Enter:

$last reboot | less

Sample output:

Fig.01: last command in action

Or, try entering:

$last reboot | head-1

Sample output:

Reboot system boot 4.9.0-3-amd64 Sat Jul 15 19:19 still running

The last command displays all logged in (and logged out) users since the wtmp file was created by looking at the file / var/log/wtmp. Every time the system restarts, the pseudo user reboot logs in. Therefore, the last reboot command will display all restart information since the log file was created.

Check the time and date of the last shutdown of the system

You can use the following command to display the date and time of the last shutdown:

$last-x | grep shutdown | head-1

Sample output:

Shutdown system down 2.6.15.4 Sun Apr 30 13:31-15:08 (01:37)

In command

-x: displays the system shutdown and operation level change information

Here are some other options for the last command:

$last$ last-x $last-x reboot$ last-x shutdown

Sample output:

Fig.01: How to view last Linux System Reboot Date/Time

Check the uptime of the system

Another order suggested by readers in the comments section is as follows:

$uptime-s

Sample output:

2017-06-2017: example of 41:51OS X/Unix/FreeBSD command to view recent restart and shutdown times

Enter the following command at the terminal:

$last reboot

The output of the sample in OS X is as follows:

Reboot ~ Fri Dec 18 23:58reboot ~ Mon Dec 14 09:54reboot ~ Wed Dec 9 23:21reboot ~ Tue Nov 17 21:52reboot ~ Tue Nov 17 06:01reboot ~ Wed Nov 11 12:14reboot ~ Sat Oct 31 13:40reboot ~ Wed Oct 28 15:56reboot ~ Wed Oct 28 11:35reboot ~ Tue Oct 27 00:00reboot ~ Sun Oct 18 17:28reboot ~ Sun Oct 18 17:11reboot ~ Mon Oct 5 09:35reboot ~ Sat Oct 3 1857 wtmp begins Sat Oct 3 18vis57

To view the shutdown date and time, enter:

$last shutdown

Sample output:

Shutdown ~ Fri Dec 18 23:57shutdown ~ Mon Dec 14 09:53shutdown ~ Wed Dec 9 23:20shutdown ~ Tue Nov 17 14:24shutdown ~ Mon Nov 16 21:15shutdown ~ Tue Nov 10 13:15shutdown ~ Sat Oct 31 13:40shutdown ~ Wed Oct 28 03:10shutdown ~ Sun Oct 18 17:27shutdown ~ Mon Oct 5 09:23 wtmp begins Sat Oct 3 18VR 57 how can I see who rebooted and shut down the machine?

You need to enable the psacct service and run the following command to view the executed commands (including the user name), and enter the lastcomm command at the terminal to view the information

# lastcomm userNameHere# lastcomm commandNameHere# lastcomm | more# lastcomm reboot# lastcomm shutdown### or check the restart and shutdown time # lastcomm | egrep 'reboot | shutdown'

Sample output:

Reboot S X root pts/0 0.00 secs Sun Dec 27 23:49shutdown S root pts/1 0.00 secs Sun Dec 27 23:45

We can see that root users restarted the machine at 23:49 local time on Tuesday, December 27 at pts/0.

Thank you for reading this article carefully. I hope the article "how to query the recent restart time of the machine in the Linux system" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report