Set Linux system time to time from /proc/version

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question



















  • 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










  • @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











  • @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














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.










share|improve this question



















  • 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










  • @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











  • @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












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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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










  • 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




    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










  • 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










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)"





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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)"





    share|improve this answer
























      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)"





      share|improve this answer






















        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)"





        share|improve this answer












        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)"






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 30 at 20:36









        xenoid

        1,8961620




        1,8961620



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)