getting uptime in Weeks, Days, Hours, Minutes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












Basically I an using conky to ssh into an android tv box and get the uptime and display it on the conky screen.



I have this so far, found on net and hacked by me but it works, please amend if its crap



uptime | awk -F'( |,|:)+' 'print int($6/7),"weeks",$8,"hours,",$9,"minutes."'


and it shows



4 weeks 1 hour 1 minute


How do I get



4 weeks **1 day** 1 hour 1 minute









share|improve this question



























    up vote
    5
    down vote

    favorite












    Basically I an using conky to ssh into an android tv box and get the uptime and display it on the conky screen.



    I have this so far, found on net and hacked by me but it works, please amend if its crap



    uptime | awk -F'( |,|:)+' 'print int($6/7),"weeks",$8,"hours,",$9,"minutes."'


    and it shows



    4 weeks 1 hour 1 minute


    How do I get



    4 weeks **1 day** 1 hour 1 minute









    share|improve this question

























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      Basically I an using conky to ssh into an android tv box and get the uptime and display it on the conky screen.



      I have this so far, found on net and hacked by me but it works, please amend if its crap



      uptime | awk -F'( |,|:)+' 'print int($6/7),"weeks",$8,"hours,",$9,"minutes."'


      and it shows



      4 weeks 1 hour 1 minute


      How do I get



      4 weeks **1 day** 1 hour 1 minute









      share|improve this question















      Basically I an using conky to ssh into an android tv box and get the uptime and display it on the conky screen.



      I have this so far, found on net and hacked by me but it works, please amend if its crap



      uptime | awk -F'( |,|:)+' 'print int($6/7),"weeks",$8,"hours,",$9,"minutes."'


      and it shows



      4 weeks 1 hour 1 minute


      How do I get



      4 weeks **1 day** 1 hour 1 minute






      linux date uptime






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 25 '17 at 21:30









      Jeff Schaller

      32.3k849110




      32.3k849110










      asked Sep 25 '17 at 19:48









      not_Rich

      334




      334




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          10
          down vote



          accepted










          Since you tag your question with Ubuntu, below is enough.



          $ uptime -p
          up 4 weeks, 1 day, 1 hour, 1 minute


          see man uptime for Ubuntu.



          -p, --pretty
          show uptime in pretty format


          Or with your own script:



          awk -F'( |,|:)+' '
          printf("%dweeks, %.fdays, %dhours, %dminutesn",
          $5/7, ($5/7-int($5/7))/0.143+.05, $7, $8)
          ' <(uptime)


          Each day~=0.143 week, and we divided the result to 0.143 to get days, then added 0.5 and with printf' s .f control it will round to next integer number (does as Ceil function).



          You may need to change $5, $7 and $8 with $6, $8 and $9.






          share|improve this answer


















          • 1




            Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
            – NickD
            Sep 25 '17 at 20:31










          • Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
            – Î±Ò“sнιη
            Sep 25 '17 at 20:48











          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%2f394397%2fgetting-uptime-in-weeks-days-hours-minutes%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
          10
          down vote



          accepted










          Since you tag your question with Ubuntu, below is enough.



          $ uptime -p
          up 4 weeks, 1 day, 1 hour, 1 minute


          see man uptime for Ubuntu.



          -p, --pretty
          show uptime in pretty format


          Or with your own script:



          awk -F'( |,|:)+' '
          printf("%dweeks, %.fdays, %dhours, %dminutesn",
          $5/7, ($5/7-int($5/7))/0.143+.05, $7, $8)
          ' <(uptime)


          Each day~=0.143 week, and we divided the result to 0.143 to get days, then added 0.5 and with printf' s .f control it will round to next integer number (does as Ceil function).



          You may need to change $5, $7 and $8 with $6, $8 and $9.






          share|improve this answer


















          • 1




            Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
            – NickD
            Sep 25 '17 at 20:31










          • Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
            – Î±Ò“sнιη
            Sep 25 '17 at 20:48















          up vote
          10
          down vote



          accepted










          Since you tag your question with Ubuntu, below is enough.



          $ uptime -p
          up 4 weeks, 1 day, 1 hour, 1 minute


          see man uptime for Ubuntu.



          -p, --pretty
          show uptime in pretty format


          Or with your own script:



          awk -F'( |,|:)+' '
          printf("%dweeks, %.fdays, %dhours, %dminutesn",
          $5/7, ($5/7-int($5/7))/0.143+.05, $7, $8)
          ' <(uptime)


          Each day~=0.143 week, and we divided the result to 0.143 to get days, then added 0.5 and with printf' s .f control it will round to next integer number (does as Ceil function).



          You may need to change $5, $7 and $8 with $6, $8 and $9.






          share|improve this answer


















          • 1




            Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
            – NickD
            Sep 25 '17 at 20:31










          • Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
            – Î±Ò“sнιη
            Sep 25 '17 at 20:48













          up vote
          10
          down vote



          accepted







          up vote
          10
          down vote



          accepted






          Since you tag your question with Ubuntu, below is enough.



          $ uptime -p
          up 4 weeks, 1 day, 1 hour, 1 minute


          see man uptime for Ubuntu.



          -p, --pretty
          show uptime in pretty format


          Or with your own script:



          awk -F'( |,|:)+' '
          printf("%dweeks, %.fdays, %dhours, %dminutesn",
          $5/7, ($5/7-int($5/7))/0.143+.05, $7, $8)
          ' <(uptime)


          Each day~=0.143 week, and we divided the result to 0.143 to get days, then added 0.5 and with printf' s .f control it will round to next integer number (does as Ceil function).



          You may need to change $5, $7 and $8 with $6, $8 and $9.






          share|improve this answer














          Since you tag your question with Ubuntu, below is enough.



          $ uptime -p
          up 4 weeks, 1 day, 1 hour, 1 minute


          see man uptime for Ubuntu.



          -p, --pretty
          show uptime in pretty format


          Or with your own script:



          awk -F'( |,|:)+' '
          printf("%dweeks, %.fdays, %dhours, %dminutesn",
          $5/7, ($5/7-int($5/7))/0.143+.05, $7, $8)
          ' <(uptime)


          Each day~=0.143 week, and we divided the result to 0.143 to get days, then added 0.5 and with printf' s .f control it will round to next integer number (does as Ceil function).



          You may need to change $5, $7 and $8 with $6, $8 and $9.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 26 '17 at 15:27

























          answered Sep 25 '17 at 20:13









          αғsнιη

          15.7k92563




          15.7k92563







          • 1




            Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
            – NickD
            Sep 25 '17 at 20:31










          • Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
            – Î±Ò“sнιη
            Sep 25 '17 at 20:48













          • 1




            Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
            – NickD
            Sep 25 '17 at 20:31










          • Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
            – Î±Ò“sнιη
            Sep 25 '17 at 20:48








          1




          1




          Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
          – NickD
          Sep 25 '17 at 20:31




          Also works on RHEL7 and Fedora 24,. so I suspect it will work in any Linux distro.
          – NickD
          Sep 25 '17 at 20:31












          Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
          – Î±Ò“sнιη
          Sep 25 '17 at 20:48





          Thanks : ) Yeah, except OSX, but awk version should work I think in all distros
          – Î±Ò“sнιη
          Sep 25 '17 at 20:48


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394397%2fgetting-uptime-in-weeks-days-hours-minutes%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Christian Cage

          How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?