-----Original Message-----
From: Kenn Humborg <kenn at bluetree.ie>
To: Conor Daly <conor.daly at met.ie>
Cc: ilug <ilug at linux.ie>
Date: 29 June 2000 17:35
Subject: RE: [ILUG] UPS for home use?
>> Hell, if it comes to it, I'll let it spend 5 minutes fscking the disk on
>> restart (now if I could just think of a way to fake the uptime to pretend
>> the power loss never happened...)
>>IIRC, someone wrote a kernel module that creates a /proc
>entry called /proc/uptime, so that you could do
>># cat big-number-of-seconds > /proc/uptime
>>to fake your uptime.
>>Later,
>Kenn
>
But that would be cheating wouldn't it. Could script something to store the
uptime and delete the record on a proper reboot but if the power goes, cat
it back to /proc/uptime.
Something like this in /etc/rc.d/init.d with stop symlinks in rc0.d and
rc6.d and start symlinks in rc1.d, rc2.d, rc3.d, rc5.d
#!/bin/bash
case in $1
start)
cat /root/stored_uptime > /proc/uptime
;;
stop)
rm -f /root/stored_uptime
;;
*)
echo useage: $0 {start|stop}
;;
esac
Then set up a cron job to do
* * * * * cat /proc/uptime > /root/stored_uptime
If the system dies from a power cut, the stored_uptime file remains and is
used to update /proc/uptime while if a proper reboot is done, it gets
deleted. Have to add the check for the existence of stored_uptime before
trying to cat it to /proc/uptime though.
All that remains then is to figure out how to differentiate between a power
cut and a system hang (not that it will hang eh?)
---
Conor Daly
Ph +353 1 8326146
conor.daly at oceanfree.net
------------------------------------------
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!