-   Linux - General (
-   -   How can I reset uptime without rebooting? Re: suspend2 issue (

evilbohdran 06-07-2006 10:26 AM

How can I reset uptime without rebooting? Re: suspend2 issue
This seems like a simple thing but I'm not sure anyone has tried to do this before. Simply I want to reset my uptime counter back to zero without rebooting.

Why would I want to? I've been using the suspend2 patches to hibernate my laptop, then resume the system at a later point. It resumes the kernel back to its original state, including uptime, so it now misreports how long the machine has been on (its value is now cumulative). I use uptime meaningfully in various scripts to measure battery life and such.

I've tried "echo '0 0' > /proc/uptime", but that is a read-only file. I've looked at the sysinfo() function, but it is readonly; there doesn't appear to be a setsysinfo() function. Lastly I could replace uptime with some script to calculate the real uptime relative to when the resume occurred, but that seems kludgy.

Thanks for any help.

My system is Gentoo, kernel 2.6.16 (suspend2-sources).

Tinkster 06-09-2006 02:02 AM

I fail to see how it misreports. I'd suggest instead of trying
to reset uptime re-writing your script(s) to read/write "run-time"
values from the scripts that run on suspend and wake-up. From
both the reality of the kernel and the machine the uptime is
what the kernel reports, not what you think it should be.


All times are GMT -5. The time now is 06:16 AM.