Find last shutdown time
Solution 1
According to your output:
shutdown system down 3.14-1-amd64 Mon Jul 21 08:43 - 22:19 (13:36)
You shutdown your system on July 21 at 08:43 and then after 13 hours and 36 minutes on July 21 at 22:19 you boot it up again. You can see how much time your system is up with uptime
command. If you want to see the last time you boot up (not shutdown) use the following command:
last -x | grep reboot
For example my output is:
reboot system boot 4.4.0-31-generic Mon Aug 1 12:59 still running
reboot system boot 4.4.0-31-generic Mon Aug 1 01:28 - 08:54 (07:25)
Now it's easy to understand that I booted up my system on August 1 at 12:59 and it's still running. And I was working with my computer for 7 hours and 25 minutes from 01:28 to 08:54 on August 1. Hope it will be useful! :-)
Solution 2
I'm using OS Fedora and command:
last -1x shutdown
shutdown system down 3.15.3-200.fc20. Fri Jul 11 12:31 - 12:31 (00:00)
wtmp begins Sat Dec 28 12:28:14 2013
Solution 3
If you are using systemd (and have journald logs permanently stored on disk), you could use journalctl -b-1
and then go to the end of the logs
Solution 4
Another good alternative is the use of the command tuptime
.
The following example lists information on the last two operating system runs, among others shutdown time:
$ tuptime -l -S-2
Startup: 1379 at 13:51:57 06/01/18
Uptime: 10 minutes and 54 seconds
Shutdown: OK at 14:02:51 06/01/18
Downtime: 19 hours, 31 minutes and 53 seconds
Startup: 1380 at 09:34:44 07/01/18
Uptime: 22 minutes and 59 seconds
Related videos on Youtube
![şaloma](https://i.stack.imgur.com/tLWUC.jpg?s=256&g=1)
şaloma
Updated on September 18, 2022Comments
-
şaloma almost 2 years
This is the command I am using:
last -x|grep shutdown | head -1
but it's giving me the duration with +2 hours:
shutdown system down 3.14-1-amd64 Mon Jul 21 08:43 - 22:19 (13:36)
the last shutdown time (08:43) is correct, but the startup time (22:19, should be 20:19) is incorrect.
Is there a better command to check how long ago the PC was shutdown? or is my DST settings or something else causing this?
PS: I am using Debian testing (Linux rig 3.14-1-amd64 #1 SMP Debian 3.14.12-1 (2014-07-11) x86_64 GNU/Linux)
-
tachomi almost 10 yearsWhich O.S. are you using?
-
Nidal almost 10 yearsAre you sure that the time is given +2 hours, I have tried it and it worked.
-
Mark Plotnick almost 10 yearsIn the reboot line that is adjacent to this shutdown line, does it also show the incorrect startup time?
-
klerk almost 10 years
who -b
gives last system boot timelast reboot
gives also what command says. If you suspect on DST settings check current date and compare it with real values and let us know -
şaloma almost 10 years@klerk
who -b
gives incorrect value:semko@rig:~$ who -b system boot 2014-07-22 00:24 semko@rig:~$ date Mon Jul 21 22:41:35 CEST 2014
. so you can see that it is off by 2 hrs fromdate
.semko@rig:~$ last reboot reboot system boot 3.14-1-amd64 Tue Jul 22 00:24 - 22:41 (-1:-42)
is the last entry, and the -1:-42 is just absurd. -
Mark Plotnick almost 10 yearsInteresting. So you're 2 hours ahead of UTC? Is your BIOS clock kept in UTC or the local time?
-
şaloma almost 10 years
-
Mark Plotnick almost 10 yearsMy hunch is that the software on Linux that records system boot time is running without knowing your correct timezone and is interpreting the hardware clock's time as UTC. Do you set your timezone using a shell variable, or do you use an
/etc/timezone
and/or/etc/localtime
file? -
şaloma almost 10 years@MarkPlotnick Well, I am using KDE's date & time module (set to local, at least that's what it shows). It's also set to sync with the europe.pool.ntp.org.
-
Mark Plotnick almost 10 yearsCan you post the contents of /etc/timezone and /etc/sysconfig/clock and the output of
ls -l /etc/localtime
? -
Mark Plotnick almost 10 yearsThey look OK. I have just one suggestion: use UTC for the BIOS time. Most Linux servers do this. As root, run
hwclock --utc
, then rundate
to check and set the correct time - it will probably be 2 hours off - then reboot. -
şaloma almost 10 yearsLet us continue this discussion in chat.
-
-
m3nda about 6 yearsThis doesn't help to known about a shutdown or restart, because you are already up at command time. This kind of question is more about "to know when the computer has went off", which is my case too. All we know about logs, but there are always a nicer way to do things, like
last
.