Subject: Re: time of shutdown / power-loss
To: Petar Bogdanovic <p+netbsd@2005.smokva.net>
From: Stefan 'Kaishakunin' Schumacher <stefan@net-tex.de>
List: netbsd-users
Date: 11/30/2005 11:13:20
--EVF5PPMfhYS0aIcm
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Also sprach Petar Bogdanovic (p+netbsd@2005.smokva.net)
> which is the most elegant way to get the time of the last=20
> system-shutdown / power loss?
You can use logger(1) to writes sth. to syslog. I have a simple
heartbeat shellskript on my servers that is started from /etc/rc.local:
while true=20
do
logger "uptime: `uptime`"
sleep 600
done
so every ten minutes `uptime` is written to /var/log/messages:
stefan@wieland {20} tail -n 1 /var/log/messages
Nov 30 11:09:05 wieland stefan: uptime 11:09AM up 1:30, 5 users,
load averages: 0.58, 0.54, 0.50
stefan@wieland {21}=20
You can adjust the sleep command to get a smaller interval, but IMO 10
minutes is sufficient. When I had a problem with one machine (was
defunct RAM) I also added `ps -ax` to the logger command, to get a
snapshot of running processes.
I am using logger since the logs are rotated and compressed, in the
first version I simply used "> uplog.txt", which than grew to much.
--=20
PGP FPR: CF74 D5F2 4871 3E5C FFFE 0130 11F4 C41E B3FB AE33
--=20
Der Geist des Kriegers sollte mit Beginn des Neujahrstages bis zum Ende=20
des Jahres vom Gedanken an seinen Tod beherrscht werden.
Daijouji Shigesuke in "Budo Shoshin Shuu"
--EVF5PPMfhYS0aIcm
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)
iD8DBQFDjXtAEfTEHrP7rjMRAu6RAJ9m/+IeshiOWI3c0rZCURg2nBOzgACeM3rH
l4TRXymGhUK6P3SulnvWpUQ=
=2TAd
-----END PGP SIGNATURE-----
--EVF5PPMfhYS0aIcm--