Check Shutdown and Reboot Date in Linux,There are lots of reasons why you’d need to discover whilst your Linux laptop shut down, restarted, or how lengthy it’s been going for walks. Most of the time this information is precious in debugging a hassle that can have took place whilst nobody was searching. Thankfully, Linux meticulously logs device events routinely on maximum distributions. Accessing that logged statistics from the command line is a breeze as properly.
Check Shutdown and Reboot Date in Linux,Last Boot
First, if you want to check whilst your pc remaining booted up, you may use the who command with the -b flag to get an exact date and time in your terminal. You don’t need root privileges, so go beforehand and check.
who -b
Check Shutdown and Reboot Date in Linux,Reboots
With the remaining command you could listing on every occasion your device has rebooted. These aren’t necessarily times when the gadget has used the reboot command or that you’ve rebooted from your computing device. Instead, it logs whenever your system booted.
last -x reboot
Check Shutdown and Reboot Date in Linux,Last Reboot
If you’d select a more concise version, best showing the ultimate time your pc booted, you could pipe the output to head and supply it with -1, telling it to best output one line. If you’d prefer the boot prior to your current one, use -2 to get each strains.
last -x reboot | head -1
Shutdowns
The last command works further with shutdowns. These are instances that your laptop close down completely. They provide a time variety when the computer was off. You can line those up with the reboots to recognise which shutdown corresponds.
last -x shutdown
Last Shutdown
Like with the reboots earlier than, you can pipe the output to head to get the last shutdown handiest. Also like earlier than, you can supply a one-of-a-kind range, like -3 to get the ultimate three shutdowns.
last -x shutdown | head -1
Uptime
Finally, whilst you want to recognize how long your pc has been strolling, you can use the uptime command to discover. Combine it with the -p flag to get plenty greater without problems readable output. You’ll get the quantity of time in days, hours, and minutes that your laptop has been on since the closing boot.
uptime -p
Hopefully, with the above instructions, you’ll be capable of discern out a sample, or maybe the reason, behind your pc’s reboots and shutdowns. If other programs are concerned, you can usually test for unique log files in “/var/log.”