How can I tell if a Linux system rebooted and determine the time of the reboot by looking at the system logs, such as /var/log/messages
?
How can I tell if a Linux system rebooted and determine the time of the reboot by looking at the system logs, such as /var/log/messages
?
Very, very easy. The
last
command parses/var/log/wtmp
for user activity including pseudo-user reboot.Use the command:
last reboot
See
man last
for more information. http://linux.die.net/man/1/lastIf the /var/log/wtmp file was rotated since your last reboot, you may be able to see prior reboots by using
last -f /var/log/wtmp.1 reboot
.It varies from distribution to distribution. Sometimes /var/log/{messages,syslog,dmesg} will include it. For one I just rebooted, my last 2 lines and the very first ones after the reboot are:
... and so-on. That shows a normal shutdown. An unexpected shutdown might not tell you the time it went offline, but you can guess based on the gap between the last message and the first depending on how noisy your system is.
Type the
uptime
command.This will tell you how long your system has been up, as well as load averages.
Edit: you can also look for a /var/log/kern.log. This should contain kernel messages only, so it will be easier to find the boot messages.
Look in your /var/log/messages or /var/log/boot logs for the time of the system boot. An example from CentOS 6...
On Ubuntu, I look for the string
\] Linux version
in/var/log/syslog
.It will match lines that look something like this: