How to check the time of shutdown and reboot in Linux
There are many reasons why you might want to find out when your Linux computer is off, reboot or how long it will run. In most cases, this information is invaluable in debugging a problem. Fortunately, Linux automatically 'meticulously' records system events on most distributions. Additionally, accessing information recorded from the command line is also very easy.
Debug by checking the shutdown time and restarting in Linux
- Last boot
- Restart
- The latest reboot
- Shutdown
- Last shutdown
- Operation time
Last boot
First, if you want to check the boot computer for the last time, you can use the who command with the -b flag to get the exact date and time in the terminal. You do not need root privileges when checking this information.
who -b
Restart
With the last command , you can list information each time the system restarts. This information does not include all times when the system has used the reboot command or when rebooting from the desktop. Instead, Linux logs every time the system starts.
last -x reboot
The latest reboot
If you like a more concise version, only showing the most recent boot time, you can switch the output to head and provide parameter -1, to request only one line. If you need information about the last 2 starts, use -2 to export both lines.
last -x reboot | head -1
Shutdown
The last command works similarly to the shutdown times. These are times when the computer is completely turned off. This information provides a time range that includes all times the computer is turned off. You can put them in parallel with the reboots to know the corresponding shutdown.
last -x shutdown
Last shutdown
As with previous reboots, you can switch the output to head to get only the information about the last shutdown. Just like before, you can provide different numbers, such as -3 to get information about the last 3 shutdowns.
last -x shutdown | head -1
Operation time
Finally, when you want to know how long your computer has been running, you can use the uptime command to find out this information. Combine uptime commands with the -p flag to get more readable output. You will receive the duration in days, hours and minutes that the computer has turned on since the last boot.
uptime -p
Hopefully, with the above commands, you can find some suggestions or even the cause behind the problem related to rebooting and shutdown. If you suspect other programs, you can check specific log files in '/ var / log'.
Hope you are succesful.
You should read it
- How to use the last command in Linux
- How to use the which command in Linux
- How to check whether a Linux PC is 64-bit or 32-bit by command line
- 8 best Linux distros for pentest
- How to use the stat command on Linux
- How to use ss command on Linux
- 11 df commands in Linux (with example)
- How to manage Linux services using Systemd
May be interested
- How to run Linux desktop using Windows Subsystem for Linuxone solution to this problem is to use windows subsystem for linux, but this tool does not have a desktop environment.
- How to compare two text files on Linux Terminalif you want to see the difference between two text files, use the diff command. this tutorial will show you how to use diff commands on linux and macos.
- What is the difference between GTK + and Qt?gtk + and qt are toolkits that developers use to structure how the application will look. these toolkits provide buttons, toolbars, sliders and user menus to see when using an application.
- How to perform multitasking on Linux Terminal with Screenwhat happens if you need to run some commands at the same time? gnu screen can help terminal perform multitasking easily. let's find out specifically through the following article!
- How to check and manage disk space in Linuxa common problem is that updates fail due to a lack of disk space, but there are some simple tests that users can perform when they encounter an error message, to keep critical systems smooth operation.
- How to open Apple Music in Linuxcan i really open apple music in linux? the answer is yes. it's just that this will be a bit more difficult and requires some resolution.