Linux系统如何查看重启记录 (linux查看谁重启记录)

作为一种开源的操作系统,Linux 在服务器和个人电脑上均有广泛应用。由于其稳定性和安全性,Linux 系统需要经常重启,以确保系统的稳定性和数据的安全。在 Linux 系统中,查看重启记录是重要的一项操作,其能帮助我们对系统的运行情况有个全面的了解。本篇文章将会介绍如何查看 Linux 系统的重启记录。

1. 使用 last 命令查看重启记录

在 Linux 系统中,last 命令可以帮助我们查看 Linux 系统的历史登录和重启记录。此命令可以查看当前系统的用户登录和注销信息、进程启动和结束信息以及重启记录等。

命令格式:last -x reboot

命令参数:

-x 显示系统关机和重新启动的原因

reboot 关键词指定要查看的事件类型

执行该命令,系统将输出该系统的重启历史记录。如下所示:

root@ubuntu:~# last -x reboot

reboot system boot 5.11.0-38-gener Thu Nov 11 12:00 still running

reboot system boot 5.11.0-38-gener Thu Nov 11 11:57 still running

reboot system boot 5.11.0-38-gener Wed Nov 3 15:44 – 12:00 (20+20:16)

reboot system boot 5.11.0-38-gener Fri Oct 29 15:35 – 15:54 (4+00:18)

reboot system boot 5.11.0-38-gener Fri Oct 29 15:30 – 15:35 (00:04)

reboot system boot 5.11.0-38-gener Fri Oct 29 15:21 – 15:30 (00:08)

shutdown system down 5.11.0-38-gener Fri Oct 29 15:20 – 15:21 (00:00)

reboot system boot 5.11.0-38-gener Thu Oct 28 13:00 – 15:21 (02:21)

shutdown system down 5.11.0-38-gener Thu Oct 28 12:59 – 13:00 (00:00)

reboot system boot 5.11.0-38-gener Wed Oct 27 13:00 – 15:21 (02:21)

shutdown system down 5.11.0-38-gener Wed Oct 27 12:59 – 13:00 (00:00)

reboot system boot 5.11.0-38-gener Tue Oct 26 13:00 – 15:21 (02:21)

shutdown system down 5.11.0-38-gener Tue Oct 26 12:59 – 13:00 (00:00)

reboot system boot 5.11.0-38-gener Mon Oct 25 13:00 – 15:21 (02:21)

shutdown system down 5.11.0-38-gener Mon Oct 25 12:59 – 13:00 (00:00)

reboot system boot 5.11.0-38-gener Fri Oct 22 13:00 – 15:21 (02:21)

shutdown system down 5.11.0-38-gener Fri Oct 22 12:59 – 13:00 (00:00)

….

从输出结果中,我们可以从右侧的时间戳中看到每次重启的时间和日期。该命令还会提供日志文件的位置,以帮助我们进一步分析系统信息。

2. 查看系统日志文件 /var/log/messages

Linux 系统中,系统事件信息都记录在日志文件里。我们可以查看特定的日志文件以检查系统运行情况。其中,/var/log/messages 日志文件包含了大多数系统日志信息,包括重启信息。

我们可以使用以下命令查看该日志文件的最后几行。

命令格式:tl -f /var/log/messages

执行该命令,可以输出该文件的最后10行,如下所示:

root@ubuntu:~# tl -f /var/log/messages

Nov 11 12:00:01 ubuntu systemd[1]: Started Session 443 of user root.

Nov 11 12:00:04 ubuntu systemd[1]: Starting Cleanup of Temporary Directories…

Nov 11 12:00:05 ubuntu systemd[1]: Started Cleanup of Temporary Directories.

Nov 11 12:02:47 ubuntu systemd[1]: Started Session 444 of user root.

Nov 11 12:03:00 ubuntu systemd[911]: Listening on GnuPG crypto daemon and IPC socket.

Nov 11 12:03:00 ubuntu systemd[911]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).

Nov 11 12:03:02 ubuntu systemd[911]: starting services took 5 + 1 + 2 != 7.

Nov 11 12:04:00 ubuntu CRON[18686]: pam_unix(cron:session): session opened for user root by (uid=0)

Nov 11 12:04:00 ubuntu CRON[18685]: pam_unix(cron:session): session opened for user root by (uid=0)

Nov 11 12:04:00 ubuntu CRON[18686]: pam_unix(cron:session): session closed for user root

我们可以在输出结果中找到特定日期和时间的日志,以了解系统重启的信息。在 /var/log/messages 文件中,我们还可以找到其他有用的系统日志信息,如错误日志和因软件升级而导致的系统重启日志等。

Linux 系统的重启记录对于系统支持和故障排除等方面都是重要的信息。通过使用 last 命令和查看系统日志文件,我们可以方便快速地了解系统的运行情况。了解如何查看系统重启记录,可以帮助我们更好地管理 Linux 系统,确保其运行的稳定性和安全性。

相关问题拓展阅读:

如何查看centos 重启日志

/var/log/boot.log 开启或重启日志。Linux系统拥有非常灵活和强大的日志功能,可以保存几乎所有的操作记录,并可以从中检索出我们需要的信息。

大部分Linux发行版默认的日志

守护进程

为 syslog,位于 /etc/syslog 或 /etc/syslogd,默认

配置文件

为 /etc/syslog.conf,任何希望生成日志的程序都可以向 syslog 发送信息。

Linux系统内核和许多程序会产生各种错误信息、警告信息和其他的提示信息,这些信息对管理员了解系统的运行状态是非常有用的,所以应宴野该把它们写到日志文件中去。完成这个过程的程序就是syslog。syslog可以根据日志昌腊的类别和

优先级

将日志保存到不同的文件中。例如,为了方便查阅,可以把内核信息与其他信息分开,单独晌迅喊保存到一个独立的日志文件中。默认配置下,日志文件通常都保存在“/var/log”目录下。

dmesg

或者

vi /etc/messages

linux查看谁重启记录的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于linux查看谁重启记录,Linux系统如何查看重启记录,如何查看centos 重启日志的信息别忘了在本站进行查找喔。


数据运维技术 » Linux系统如何查看重启记录 (linux查看谁重启记录)