uptime -s changing reported time
I have a script that relies in time Ubuntu 18.04 is started found by:
uptime -s
I save that value in a file when I run the script. I noticed when I started Ubuntu that time was:
uptime -s
2019-01-07 18:01:59
After running for a bit more than two hours, same command reports now a different time (I remained logged in same account all this time):
uptime -s
2019-01-07 18:01:58
I would expect the command reports same time within same login session. But somehow time changes with 1 second (it is earlier now).
Is this an OS or tool issue?
https://elixir.bootlin.com/linux/latest/source/fs/proc/uptime.c
struct timespec64 uptime;
ktime_get_boottime_ts64(&uptime);
How can I get system up time without such fluctuation?
Update:
I though I found the answer in: Linux: Getting date & time of system startup
But I was wrong, it just luck, after running a few more tests, one can see it is OS problem, the time rotates between 58 and 59 depending on nanoseconds:
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.670091767
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.627339874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.708332394
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.821526069
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.604129974
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.469767199
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.264900963
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.986611962
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.851955874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.958194732
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.066728481
I seems, there is no reliable system uptime to second level.
linux ubuntu
New contributor
add a comment |
I have a script that relies in time Ubuntu 18.04 is started found by:
uptime -s
I save that value in a file when I run the script. I noticed when I started Ubuntu that time was:
uptime -s
2019-01-07 18:01:59
After running for a bit more than two hours, same command reports now a different time (I remained logged in same account all this time):
uptime -s
2019-01-07 18:01:58
I would expect the command reports same time within same login session. But somehow time changes with 1 second (it is earlier now).
Is this an OS or tool issue?
https://elixir.bootlin.com/linux/latest/source/fs/proc/uptime.c
struct timespec64 uptime;
ktime_get_boottime_ts64(&uptime);
How can I get system up time without such fluctuation?
Update:
I though I found the answer in: Linux: Getting date & time of system startup
But I was wrong, it just luck, after running a few more tests, one can see it is OS problem, the time rotates between 58 and 59 depending on nanoseconds:
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.670091767
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.627339874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.708332394
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.821526069
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.604129974
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.469767199
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.264900963
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.986611962
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.851955874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.958194732
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.066728481
I seems, there is no reliable system uptime to second level.
linux ubuntu
New contributor
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30
add a comment |
I have a script that relies in time Ubuntu 18.04 is started found by:
uptime -s
I save that value in a file when I run the script. I noticed when I started Ubuntu that time was:
uptime -s
2019-01-07 18:01:59
After running for a bit more than two hours, same command reports now a different time (I remained logged in same account all this time):
uptime -s
2019-01-07 18:01:58
I would expect the command reports same time within same login session. But somehow time changes with 1 second (it is earlier now).
Is this an OS or tool issue?
https://elixir.bootlin.com/linux/latest/source/fs/proc/uptime.c
struct timespec64 uptime;
ktime_get_boottime_ts64(&uptime);
How can I get system up time without such fluctuation?
Update:
I though I found the answer in: Linux: Getting date & time of system startup
But I was wrong, it just luck, after running a few more tests, one can see it is OS problem, the time rotates between 58 and 59 depending on nanoseconds:
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.670091767
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.627339874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.708332394
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.821526069
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.604129974
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.469767199
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.264900963
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.986611962
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.851955874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.958194732
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.066728481
I seems, there is no reliable system uptime to second level.
linux ubuntu
New contributor
I have a script that relies in time Ubuntu 18.04 is started found by:
uptime -s
I save that value in a file when I run the script. I noticed when I started Ubuntu that time was:
uptime -s
2019-01-07 18:01:59
After running for a bit more than two hours, same command reports now a different time (I remained logged in same account all this time):
uptime -s
2019-01-07 18:01:58
I would expect the command reports same time within same login session. But somehow time changes with 1 second (it is earlier now).
Is this an OS or tool issue?
https://elixir.bootlin.com/linux/latest/source/fs/proc/uptime.c
struct timespec64 uptime;
ktime_get_boottime_ts64(&uptime);
How can I get system up time without such fluctuation?
Update:
I though I found the answer in: Linux: Getting date & time of system startup
But I was wrong, it just luck, after running a few more tests, one can see it is OS problem, the time rotates between 58 and 59 depending on nanoseconds:
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.670091767
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.627339874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.708332394
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.821526069
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.604129974
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.469767199
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.264900963
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.986611962
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.851955874
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:58.958194732
$ date -d "`cut -f1 -d. /proc/uptime` seconds ago" +"%F %T.%N"
2019-01-07 18:01:59.066728481
I seems, there is no reliable system uptime to second level.
linux ubuntu
linux ubuntu
New contributor
New contributor
edited Jan 7 at 19:46
ppp
New contributor
asked Jan 7 at 19:21
pppppp
11
11
New contributor
New contributor
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30
add a comment |
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30
add a comment |
1 Answer
1
active
oldest
votes
Found an answer here:
Linux: Getting date & time of system startup
This command seems to give correct result, unlike uptime -s
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Example:
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Mo 7. Jan 18:01:59 CET 2019
It seems uptime -s is not reliable.
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
ppp is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1391618%2fuptime-s-changing-reported-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Found an answer here:
Linux: Getting date & time of system startup
This command seems to give correct result, unlike uptime -s
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Example:
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Mo 7. Jan 18:01:59 CET 2019
It seems uptime -s is not reliable.
New contributor
add a comment |
Found an answer here:
Linux: Getting date & time of system startup
This command seems to give correct result, unlike uptime -s
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Example:
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Mo 7. Jan 18:01:59 CET 2019
It seems uptime -s is not reliable.
New contributor
add a comment |
Found an answer here:
Linux: Getting date & time of system startup
This command seems to give correct result, unlike uptime -s
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Example:
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Mo 7. Jan 18:01:59 CET 2019
It seems uptime -s is not reliable.
New contributor
Found an answer here:
Linux: Getting date & time of system startup
This command seems to give correct result, unlike uptime -s
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Example:
date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Mo 7. Jan 18:01:59 CET 2019
It seems uptime -s is not reliable.
New contributor
New contributor
answered Jan 7 at 19:27
pppppp
11
11
New contributor
New contributor
add a comment |
add a comment |
ppp is a new contributor. Be nice, and check out our Code of Conduct.
ppp is a new contributor. Be nice, and check out our Code of Conduct.
ppp is a new contributor. Be nice, and check out our Code of Conduct.
ppp is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1391618%2fuptime-s-changing-reported-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of Linux: Getting date & time of system startup
– bummi
Jan 7 at 19:30