You are not logged in.

#1 2009-08-28 04:55:02

jo3
Member
Registered: 2007-08-18
Posts: 112

How to tell when the system was shut down?

I'm curious to know what time my system lost power, whats a good way to tell? I have been checking the logs to get the last entry times but was curioius if there were other methods of telling when the box's power was interrupted? hmm

Offline

#2 2009-08-28 05:08:56

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: How to tell when the system was shut down?

I suppose if it suddenly lost power then, no.
If it was shutdown then yes.

cat /var/log/user.log


neutral

Offline

#3 2009-08-29 02:01:55

tkdfighter
Member
From: Switzerland
Registered: 2009-01-28
Posts: 126

Re: How to tell when the system was shut down?

Sometimes there's a setting in BIOS to boot the system whenever it has power, which will give you a rough estimate of when it went down.

Offline

#4 2009-08-29 03:49:36

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: How to tell when the system was shut down?

Planned reboots:

last reboot

Last edited by lucke (2009-08-29 03:51:04)

Offline

#5 2009-08-29 04:05:13

majiq
Member
Registered: 2009-03-06
Posts: 259

Re: How to tell when the system was shut down?

You can use the MARK lines in /var/log/everything.log to get it down to a twenty minute slice, probably.

Offline

#6 2009-08-29 06:27:00

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: How to tell when the system was shut down?

jo3 wrote:

I'm curious to know what time my system lost power, whats a good way to tell? I have been checking the logs to get the last entry times but was curioius if there were other methods of telling when the box's power was interrupted? hmm

A rather ghetto way of doing it:

#!/bin/bash
log="/var/log/uptime-poll"
pollsecs=10

echo $$ > /var/run/uptime-poll.pid

if [[ -f "$log.tmp" ]]; then
    echo "Lost power at:  `cut -d';' -f2 "$log.tmp"`" >> "$log.log"
fi

while :; do
  date +'%s;%D %T' > "$log.tmp"
  sleep $pollsecs
done

...and in /etc/rc.local.shutdown...

killall $(cat /var/run/uptime-poll.pid)
rm /var/run/uptime-poll.pid
rm /var/log/uptime-poll.tmp

Last edited by Wintervenom (2009-08-29 06:37:29)

Offline

Board footer

Powered by FluxBB