How to choose columns for top command in batch mode?











up vote
6
down vote

favorite
2












$ top -bn1 | head

top - 15:16:52 up 11 days, 5:01, 4 users, load average: 0,00, 0,03, 0,11
Tasks: 411 total, 1 running, 408 sleeping, 0 stopped, 2 zombie
%Cpu(s): 4,5 us, 0,6 sy, 0,0 ni, 94,5 id, 0,4 wa, 0,0 hi, 0,0 si, 0,0 st
KiB Mem: 16403396 total, 8546712 used, 7856684 free, 711904 buffers
KiB Swap: 16744444 total, 0 used, 16744444 free. 5160648 cached Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 33772 3148 1476 S 0,0 0,0 0:06.04 init
2 root 20 0 0 0 0 S 0,0 0,0 0:00.03 kthreadd
3 root 20 0 0 0 0 S 0,0 0,0 0:02.30 ksoftirqd/0


How can I make top return:




  • PID

  • COMMAND

  • %CPU

  • %MEM


  • TIME (not TIME+)


in batch mode?










share|improve this question


























    up vote
    6
    down vote

    favorite
    2












    $ top -bn1 | head

    top - 15:16:52 up 11 days, 5:01, 4 users, load average: 0,00, 0,03, 0,11
    Tasks: 411 total, 1 running, 408 sleeping, 0 stopped, 2 zombie
    %Cpu(s): 4,5 us, 0,6 sy, 0,0 ni, 94,5 id, 0,4 wa, 0,0 hi, 0,0 si, 0,0 st
    KiB Mem: 16403396 total, 8546712 used, 7856684 free, 711904 buffers
    KiB Swap: 16744444 total, 0 used, 16744444 free. 5160648 cached Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    1 root 20 0 33772 3148 1476 S 0,0 0,0 0:06.04 init
    2 root 20 0 0 0 0 S 0,0 0,0 0:00.03 kthreadd
    3 root 20 0 0 0 0 S 0,0 0,0 0:02.30 ksoftirqd/0


    How can I make top return:




    • PID

    • COMMAND

    • %CPU

    • %MEM


    • TIME (not TIME+)


    in batch mode?










    share|improve this question
























      up vote
      6
      down vote

      favorite
      2









      up vote
      6
      down vote

      favorite
      2






      2





      $ top -bn1 | head

      top - 15:16:52 up 11 days, 5:01, 4 users, load average: 0,00, 0,03, 0,11
      Tasks: 411 total, 1 running, 408 sleeping, 0 stopped, 2 zombie
      %Cpu(s): 4,5 us, 0,6 sy, 0,0 ni, 94,5 id, 0,4 wa, 0,0 hi, 0,0 si, 0,0 st
      KiB Mem: 16403396 total, 8546712 used, 7856684 free, 711904 buffers
      KiB Swap: 16744444 total, 0 used, 16744444 free. 5160648 cached Mem

      PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
      1 root 20 0 33772 3148 1476 S 0,0 0,0 0:06.04 init
      2 root 20 0 0 0 0 S 0,0 0,0 0:00.03 kthreadd
      3 root 20 0 0 0 0 S 0,0 0,0 0:02.30 ksoftirqd/0


      How can I make top return:




      • PID

      • COMMAND

      • %CPU

      • %MEM


      • TIME (not TIME+)


      in batch mode?










      share|improve this question













      $ top -bn1 | head

      top - 15:16:52 up 11 days, 5:01, 4 users, load average: 0,00, 0,03, 0,11
      Tasks: 411 total, 1 running, 408 sleeping, 0 stopped, 2 zombie
      %Cpu(s): 4,5 us, 0,6 sy, 0,0 ni, 94,5 id, 0,4 wa, 0,0 hi, 0,0 si, 0,0 st
      KiB Mem: 16403396 total, 8546712 used, 7856684 free, 711904 buffers
      KiB Swap: 16744444 total, 0 used, 16744444 free. 5160648 cached Mem

      PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
      1 root 20 0 33772 3148 1476 S 0,0 0,0 0:06.04 init
      2 root 20 0 0 0 0 S 0,0 0,0 0:00.03 kthreadd
      3 root 20 0 0 0 0 S 0,0 0,0 0:02.30 ksoftirqd/0


      How can I make top return:




      • PID

      • COMMAND

      • %CPU

      • %MEM


      • TIME (not TIME+)


      in batch mode?







      linux top






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 14 '16 at 14:20









      Raffael

      5093625




      5093625






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          Best method I could find:




          • run top in standard mode

          • use F to configure column

          • then use W to save the view as default


          This default view will also be used for the batch mode.






          share|improve this answer






























            up vote
            1
            down vote













            I did not want to affect my whole user by overwriting the user .toprc, so I came up with an solution to have a separate configuration per use-case.

            You can make top use a custom configuration file instead of the one in your users home directory.

            Just change the HOME variable to a custom directory containing the .toprc file for your needs.



            # TOPRC_PROFILE_DIRECTORY contains .toprc (or can be created by saving using shift+w after configuring using keybindings) 
            TOPRC_PROFILE_DIRECTORY="<your-directory>"
            HOME="$TOPRC_PROFILE_DIRECTORY" top





            share|improve this answer




















              protected by Community Dec 5 at 10:57



              Thank you for your interest in this question.
              Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



              Would you like to answer one of these unanswered questions instead?














              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote













              Best method I could find:




              • run top in standard mode

              • use F to configure column

              • then use W to save the view as default


              This default view will also be used for the batch mode.






              share|improve this answer



























                up vote
                3
                down vote













                Best method I could find:




                • run top in standard mode

                • use F to configure column

                • then use W to save the view as default


                This default view will also be used for the batch mode.






                share|improve this answer

























                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  Best method I could find:




                  • run top in standard mode

                  • use F to configure column

                  • then use W to save the view as default


                  This default view will also be used for the batch mode.






                  share|improve this answer














                  Best method I could find:




                  • run top in standard mode

                  • use F to configure column

                  • then use W to save the view as default


                  This default view will also be used for the batch mode.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 19 '17 at 13:00









                  bertieb

                  5,537112342




                  5,537112342










                  answered Apr 19 '17 at 12:40









                  Nimrods

                  312




                  312
























                      up vote
                      1
                      down vote













                      I did not want to affect my whole user by overwriting the user .toprc, so I came up with an solution to have a separate configuration per use-case.

                      You can make top use a custom configuration file instead of the one in your users home directory.

                      Just change the HOME variable to a custom directory containing the .toprc file for your needs.



                      # TOPRC_PROFILE_DIRECTORY contains .toprc (or can be created by saving using shift+w after configuring using keybindings) 
                      TOPRC_PROFILE_DIRECTORY="<your-directory>"
                      HOME="$TOPRC_PROFILE_DIRECTORY" top





                      share|improve this answer

























                        up vote
                        1
                        down vote













                        I did not want to affect my whole user by overwriting the user .toprc, so I came up with an solution to have a separate configuration per use-case.

                        You can make top use a custom configuration file instead of the one in your users home directory.

                        Just change the HOME variable to a custom directory containing the .toprc file for your needs.



                        # TOPRC_PROFILE_DIRECTORY contains .toprc (or can be created by saving using shift+w after configuring using keybindings) 
                        TOPRC_PROFILE_DIRECTORY="<your-directory>"
                        HOME="$TOPRC_PROFILE_DIRECTORY" top





                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          I did not want to affect my whole user by overwriting the user .toprc, so I came up with an solution to have a separate configuration per use-case.

                          You can make top use a custom configuration file instead of the one in your users home directory.

                          Just change the HOME variable to a custom directory containing the .toprc file for your needs.



                          # TOPRC_PROFILE_DIRECTORY contains .toprc (or can be created by saving using shift+w after configuring using keybindings) 
                          TOPRC_PROFILE_DIRECTORY="<your-directory>"
                          HOME="$TOPRC_PROFILE_DIRECTORY" top





                          share|improve this answer












                          I did not want to affect my whole user by overwriting the user .toprc, so I came up with an solution to have a separate configuration per use-case.

                          You can make top use a custom configuration file instead of the one in your users home directory.

                          Just change the HOME variable to a custom directory containing the .toprc file for your needs.



                          # TOPRC_PROFILE_DIRECTORY contains .toprc (or can be created by saving using shift+w after configuring using keybindings) 
                          TOPRC_PROFILE_DIRECTORY="<your-directory>"
                          HOME="$TOPRC_PROFILE_DIRECTORY" top






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 11 at 8:41









                          Thomas

                          11314




                          11314

















                              protected by Community Dec 5 at 10:57



                              Thank you for your interest in this question.
                              Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                              Would you like to answer one of these unanswered questions instead?



                              Popular posts from this blog

                              flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                              Mangá

                               ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕