caclulate total log in time to network

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











up vote
2
down vote

favorite












I have this log file which is recording the log in/ log out sessions by users to the network



[10:21:10] User logged in 
[13:59:42] User logged out
[15:42:00] User logged in
[16:42:13] User logged out
[11:15:02] User logged in
[11:42:23] User logged out


I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.



in this example it will be 5:06:06 hours










share|improve this question









New contributor




Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    I have this log file which is recording the log in/ log out sessions by users to the network



    [10:21:10] User logged in 
    [13:59:42] User logged out
    [15:42:00] User logged in
    [16:42:13] User logged out
    [11:15:02] User logged in
    [11:42:23] User logged out


    I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.



    in this example it will be 5:06:06 hours










    share|improve this question









    New contributor




    Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have this log file which is recording the log in/ log out sessions by users to the network



      [10:21:10] User logged in 
      [13:59:42] User logged out
      [15:42:00] User logged in
      [16:42:13] User logged out
      [11:15:02] User logged in
      [11:42:23] User logged out


      I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.



      in this example it will be 5:06:06 hours










      share|improve this question









      New contributor




      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have this log file which is recording the log in/ log out sessions by users to the network



      [10:21:10] User logged in 
      [13:59:42] User logged out
      [15:42:00] User logged in
      [16:42:13] User logged out
      [11:15:02] User logged in
      [11:42:23] User logged out


      I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.



      in this example it will be 5:06:06 hours







      logs






      share|improve this question









      New contributor




      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday





















      New contributor




      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      Cellman

      133




      133




      New contributor




      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Cellman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You can try sed and awk for this task:



           cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'

          5:06:06


          sed will line up "login" and "logout" time frames per user, then awk will do time calculation for the relevant columns.






          share|improve this answer
















          • 1




            This is brilliant!! Thank you very much !
            – Cellman
            yesterday










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



          );






          Cellman is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473801%2fcaclulate-total-log-in-time-to-network%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
          1
          down vote



          accepted










          You can try sed and awk for this task:



           cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'

          5:06:06


          sed will line up "login" and "logout" time frames per user, then awk will do time calculation for the relevant columns.






          share|improve this answer
















          • 1




            This is brilliant!! Thank you very much !
            – Cellman
            yesterday














          up vote
          1
          down vote



          accepted










          You can try sed and awk for this task:



           cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'

          5:06:06


          sed will line up "login" and "logout" time frames per user, then awk will do time calculation for the relevant columns.






          share|improve this answer
















          • 1




            This is brilliant!! Thank you very much !
            – Cellman
            yesterday












          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You can try sed and awk for this task:



           cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'

          5:06:06


          sed will line up "login" and "logout" time frames per user, then awk will do time calculation for the relevant columns.






          share|improve this answer












          You can try sed and awk for this task:



           cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'

          5:06:06


          sed will line up "login" and "logout" time frames per user, then awk will do time calculation for the relevant columns.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Goro

          7,57753371




          7,57753371







          • 1




            This is brilliant!! Thank you very much !
            – Cellman
            yesterday












          • 1




            This is brilliant!! Thank you very much !
            – Cellman
            yesterday







          1




          1




          This is brilliant!! Thank you very much !
          – Cellman
          yesterday




          This is brilliant!! Thank you very much !
          – Cellman
          yesterday










          Cellman is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          Cellman is a new contributor. Be nice, and check out our Code of Conduct.












          Cellman is a new contributor. Be nice, and check out our Code of Conduct.











          Cellman is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473801%2fcaclulate-total-log-in-time-to-network%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?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay