LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-13-2010, 11:20 AM   #1
ghusband
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
How do I change "uptime"?


Being a newbie, I did check for similar threads before posting this message. There is an existing thread that contains a very similar question to mine, but since the existing thread is approx. 7 years old, I thought I would go ahead and post my question.

I am wondering how I can change "uptime" on a Linux 2.6 box. I want to do this to test a complex wireless system that contains multiple Linux boxes.

I am able to change "uptime" on a Solaris or VxWorks box with "lbolt" and "tickSet" commands respectively. But these commands do not work on Linux boxes (no surprise there).

Any ideas out there?

Thanks.
 
Old 04-13-2010, 12:16 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

That's a bit like a used car salesman asking "How can I set the odometer back?"

I'm not sure you *can* change it; I'm not sure you *should* change it (in the sense "I'm not sure what might break if you tried").

Nevertheless...

Your best bet is to see if you can modify it via "/proc/uptime":

http://www.redhat.com/docs/manuals/e...oc-uptime.html

http://www.redhat.com/docs/manuals/l...e/ch-proc.html

'Hope that helps .. PSM
 
Old 04-13-2010, 01:40 PM   #3
ghusband
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for your quick response. You touched on one of my goals for changing "uptime" - to see what does break. This is somewhat of an "adversarial" test to see how the system would handle any changes to "uptime".

Anyway, when logged on as "root", and changing /proc/uptime to have write permissions, I tried to change /proc/uptime with "echo xxxxx > /proc/uptime" (where xxxxx is a number of seconds). Either the echo command does not work or my change is immediately over-written by some application because I do not see the new second value in /proc/uptime.

Perhaps /proc/uptime is not changeable in that configuration changes to this file are not communicated to the kernel?
 
Old 04-13-2010, 03:43 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,011

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
AFAIK uptime just asks the kernel how long it has been running for.
The kernel replies.
The answer is not configurable. And why should it be? That would be like asking the kernel to lie.

If you want a different uptime result, you'll have to reboot. Then your uptime will start from the time the kernel's uptime routine was launched.

I do not understand what this has to do with testing "a complex wireless system that contains multiple Linux boxes."

What, exactly, are you trying to do?
 
1 members found this post helpful.
Old 04-13-2010, 04:40 PM   #5
ghusband
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi,

The intent behind changing "uptime" is to walk through various age points and observe system behavior. For example, here are a couple of the defined "magic" age points that are used in my test script:

Power of 2 Integer Value Age Pt (Days) Age Pt (Seconds)
2^7 128 5.3333333333 460800
2^8 256 10.6666666667 921600

For each age point, certain components have uptime set 90 minutes prior to that age point, then the script sleeps for 2.5 hours to let the system run through that age point. After the 2.5 hours expires, the uptime is set to the next age point
(minus 90 minutes). The age points above could be associated with timers using a char vs. an unsigned char, and the goal here would be to catch improper use of a char for storing a timer value. So I would like to be able to increase the uptime counter to be able to walk through the data points (and several others) listed above.

Hope that clarifies a bit. Our test systems get booted periodically so the uptime values we see in our test labs don't really reflect what may (or should) be seen in the field.
 
Old 04-13-2010, 04:58 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,011

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
Hope that clarifies a bit.
No, not at all. Your post makes no sense.

Again, I ask What are you trying to do?

Please try to explain your situation better. Some details would be good.
 
Old 04-13-2010, 07:19 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,198
Blog Entries: 3

Rep: Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426
Hi,

Instead of 'uptime' why not use 'hwclock' to control your events.

Quote:
excerpt from 'man hwclock';

hwclock - query and set the hardware clock (RTC)
The RTC would allow you to do what you have presented so far.
 
Old 04-14-2010, 02:48 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,269

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
I don't believe you can (easily) do what you want - unless you can convince your application(s) to use another (munged) time reference.
/proc is not a "normal" filesystem in that it (usually) has no persistence. The data you see by reading /proc/uptime is created in response to you reading it. That particular "file" is read only - as are most. The code that provides the data ignores any attempt to update the "file", even if it were successful.
The code is quite straightforward ../fs/proc/uptime.c

Playing with the RTC won't help either as that is only read at boot AFAIK.
 
Old 04-14-2010, 04:57 AM   #9
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
Originally Posted by ghusband View Post
For each age point, certain components have uptime set 90 minutes prior to that age point, then the script sleeps for 2.5 hours to let the system run through that age point. After the 2.5 hours expires, the uptime is set to the next age point
(minus 90 minutes). The age points above could be associated with timers using a char vs. an unsigned char, and the goal here would be to catch improper use of a char for storing a timer value. So I would like to be able to increase the uptime counter to be able to walk through the data points (and several others) listed above.

Hope that clarifies a bit. Our test systems get booted periodically so the uptime values we see in our test labs don't really reflect what may (or should) be seen in the field.
Thinking this over, I don't see what benefit would it give to be able to change uptime just to get it look like the machine had been running for a different time than it really has. Physically nothing has changed, so you're in a way making up results if something seems to change (i.e. the reason for that change isn't the actual uptime, but a change in plain numbers). And if you're only interested in what happens if your input (uptime) changes, you could just as well make an artificial input, for example a script that returned an "uptime" chosen by you. Your test would not know the difference, because the underlying physical system was exactly the same, the only thing changing the output of "uptime", which you can replace with whatever you like.

I hope I understood you wrong (if I did, please be patient and explain it thouroughly again, thank you), but if I didn't and you really want reliable results, all you can do is run the machines (rebooting if and when needed) to the uptimes you want to check and thus get proper results.
 
Old 04-14-2010, 07:52 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,198
Blog Entries: 3

Rep: Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426
Hi,

I don't see why it would be a problem using the 'hwclock' to setup a period timer;

Quote:
excerpt from 'man hwclock';

DESCRIPTION
hwclock is a tool for accessing the Hardware Clock. You can display the current time, set the
Hardware Clock to a specified time, set the Hardware Clock to the System Time, and set the Sys-
tem Time from the Hardware Clock.

You can also run hwclock periodically to insert or remove time from the Hardware Clock to com-
pensate for systematic drift (where the clock consistently gains or loses time at a certain
rate if left to run).
Somewhat along the lines of what the OP has stipulated. The task would require the sysclock and hwclock to be used along with stored variables.
 
Old 03-31-2014, 05:14 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,194

Rep: Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567
Quote:
Originally Posted by ghusband View Post
Hi,

The intent behind changing "uptime" is to walk through various age points and observe system behavior. For example, here are a couple of the defined "magic" age points that are used in my test script:

Power of 2 Integer Value Age Pt (Days) Age Pt (Seconds)
2^7 128 5.3333333333 460800
2^8 256 10.6666666667 921600

For each age point, certain components have uptime set 90 minutes prior to that age point, then the script sleeps for 2.5 hours to let the system run through that age point. After the 2.5 hours expires, the uptime is set to the next age point
(minus 90 minutes). The age points above could be associated with timers using a char vs. an unsigned char, and the goal here would be to catch improper use of a char for storing a timer value. So I would like to be able to increase the uptime counter to be able to walk through the data points (and several others) listed above.

Hope that clarifies a bit. Our test systems get booted periodically so the uptime values we see in our test labs don't really reflect what may (or should) be seen in the field.
Uptime isn't what you want then. All uptime does is measure the elapsed time since the last boot - it isn't used for anything.

You want to set the system DATE to some value and see what happens when it crosses that date (jan 1 1970 at 0:00:00 is when the system clock starts, and negative numbers are allowed).

There was a 32 bit overflow in 2038... but that won't overflow on 64 bit systems (ints were changed to 64 bit values during system compilation... and it may even have been changed on 32 bit systems - haven't looked recently).

Applications use the system date - not the uptime for timing things.

Now, in some circumstances, there is a delta time used for timing things (usually very short timing). But again, the uptime is not used to compute the short timing interval.

One last thing: a reference to the UNIX time (used by Linux):

http://en.wikipedia.org/wiki/Unix_time

Last edited by jpollard; 03-31-2014 at 05:18 PM.
 
  


Reply

Tags
linux, uptime


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 03:29 AM
Extracting "Hours" from uptime in a BASH script? BassKozz Linux - General 16 02-17-2009 08:15 PM
how can i change my vga driver from "vesa" to "savage" mojarron Slackware 1 03-24-2005 07:16 AM
"Sysmetrix"-like tool (desktop display of space, uptime, etc) Gag Halfrunt Linux - Newbie 1 12-04-2004 10:44 PM
Can you change the "title" under your name that says "member" or "newbie&qu Whitehat LQ Suggestions & Feedback 3 11-19-2003 06:32 PM


All times are GMT -5. The time now is 03:08 PM.

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