Set Linux system time to time from /proc/version

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
What sequence of awk, sed, and/or cut commands can I use to take the date at the end of /proc/version, for example
Linux version 4.15.7 (user@system) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #233 SMP Sat Mar 10 11:40:22 EST 2018
and convert it to a format that can be passed to the date command to set the system time? This is going to be used to set the default time of an embedded Linux system, so it needs to work with the Busybox utils.
linux text-processing date proc
add a comment |Â
up vote
0
down vote
favorite
What sequence of awk, sed, and/or cut commands can I use to take the date at the end of /proc/version, for example
Linux version 4.15.7 (user@system) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #233 SMP Sat Mar 10 11:40:22 EST 2018
and convert it to a format that can be passed to the date command to set the system time? This is going to be used to set the default time of an embedded Linux system, so it needs to work with the Busybox utils.
linux text-processing date proc
1
What have you tried so far? And do you know about thefake-hwclockpackage available for systems with no battery backed RTC capability?
â roaima
Sep 30 at 20:37
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, andfake-hwclockdoesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.
â Billy
Sep 30 at 20:47
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
What sequence of awk, sed, and/or cut commands can I use to take the date at the end of /proc/version, for example
Linux version 4.15.7 (user@system) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #233 SMP Sat Mar 10 11:40:22 EST 2018
and convert it to a format that can be passed to the date command to set the system time? This is going to be used to set the default time of an embedded Linux system, so it needs to work with the Busybox utils.
linux text-processing date proc
What sequence of awk, sed, and/or cut commands can I use to take the date at the end of /proc/version, for example
Linux version 4.15.7 (user@system) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #233 SMP Sat Mar 10 11:40:22 EST 2018
and convert it to a format that can be passed to the date command to set the system time? This is going to be used to set the default time of an embedded Linux system, so it needs to work with the Busybox utils.
linux text-processing date proc
linux text-processing date proc
edited Sep 30 at 21:22
Jeff Schaller
33.6k851113
33.6k851113
asked Sep 30 at 20:28
Billy
186116
186116
1
What have you tried so far? And do you know about thefake-hwclockpackage available for systems with no battery backed RTC capability?
â roaima
Sep 30 at 20:37
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, andfake-hwclockdoesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.
â Billy
Sep 30 at 20:47
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56
add a comment |Â
1
What have you tried so far? And do you know about thefake-hwclockpackage available for systems with no battery backed RTC capability?
â roaima
Sep 30 at 20:37
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, andfake-hwclockdoesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.
â Billy
Sep 30 at 20:47
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56
1
1
What have you tried so far? And do you know about the
fake-hwclock package available for systems with no battery backed RTC capability?â roaima
Sep 30 at 20:37
What have you tried so far? And do you know about the
fake-hwclock package available for systems with no battery backed RTC capability?â roaima
Sep 30 at 20:37
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, and
fake-hwclock doesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.â Billy
Sep 30 at 20:47
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, and
fake-hwclock doesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.â Billy
Sep 30 at 20:47
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
date is fairly lenient and will accept about anything that makes sense. Looking at your /proc/version you just need to cut it on SMP:
date -s "$(sed 's/.* SMP //' /proc/version)"
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
date is fairly lenient and will accept about anything that makes sense. Looking at your /proc/version you just need to cut it on SMP:
date -s "$(sed 's/.* SMP //' /proc/version)"
add a comment |Â
up vote
4
down vote
accepted
date is fairly lenient and will accept about anything that makes sense. Looking at your /proc/version you just need to cut it on SMP:
date -s "$(sed 's/.* SMP //' /proc/version)"
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
date is fairly lenient and will accept about anything that makes sense. Looking at your /proc/version you just need to cut it on SMP:
date -s "$(sed 's/.* SMP //' /proc/version)"
date is fairly lenient and will accept about anything that makes sense. Looking at your /proc/version you just need to cut it on SMP:
date -s "$(sed 's/.* SMP //' /proc/version)"
answered Sep 30 at 20:36
xenoid
1,8961620
1,8961620
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472456%2fset-linux-system-time-to-time-from-proc-version%23new-answer', 'question_page');
);
Post as a guest
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
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
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
1
What have you tried so far? And do you know about the
fake-hwclockpackage available for systems with no battery backed RTC capability?â roaima
Sep 30 at 20:37
@roaima This is for an initramfs that listens for recovery attempts and if it doesn't get any, tries to mount the real root filesystem and boot. I would like the default startup time to be as late as possible (but not in the future) without updating the initramfs. I did a quick manpage search, and
fake-hwclockdoesn't seem like it fits this purpose; any time it wrote to the 'file system' would be lost when the real file system gets mounted or the system reboots.â Billy
Sep 30 at 20:47
Billy that's fine. Didn't want you not to know about that package, and since I didn't have knowledge of your environment I couldn't call whether or not it might be useful to you.
â roaima
Sep 30 at 20:54
@roaima No problem at all. That package might actually come in handy for the post-initramfs system, with has a non-volatile filesystem.
â Billy
Sep 30 at 20:56