Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-07-2006, 11:26 AM   #1
LQ Newbie
Registered: Sep 2005
Distribution: Gentoo
Posts: 5

Rep: Reputation: 0
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).
Old 06-09-2006, 03:02 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer rehibernates right away after waking up, using Suspend2. cellist Linux - Laptop and Netbook 1 03-19-2006 05:55 PM
suspend2 in mm kernels? is there an easier way? cheater1034 Linux - Software 0 03-07-2006 10:47 PM
suspend2 and ATI tanaselia Linux - Hardware 3 01-25-2006 04:14 PM
suspend2 2.6.14 missing kernel options cyberjun Linux - Software 1 11-19-2005 08:27 AM
uptime has reset itself, but the machine hasnt rebooted SkiTz0.BiLL-BoB Linux - Software 2 03-14-2004 01:33 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration