3

I'm running this:

$ htop --pid=3907,3940,3941,3947

and would like to make the CPU/Memory at the top only count those PIDs. Is this possible?

Other questions

Also, are there flags for:

  1. enter 'tree' mode on startup, or
  2. change columns displayed?

I'm trying to do it in a script, I know there are interactive methods.

2

Q#1: make the CPU/Memory at the top only count those PIDs. Is this possible?

Unfortunately no top and htop do not provide a mechanism for only showing the individualized load in the upper portion of their output. However the CPU/Memory resources are displayed per process as 2 of the columns of output for each PID.

enter 'tree' mode on startup, or

You can configure htop so that these are the defaults. If you toggle tree view so that it's enabled and then exit htop using q or F10 when you re-launch it the tree view should persist, it's now the default.

change columns displayed?

The same applies to the columns. Select the ones you want and they'll become the defaults as well.

NOTE: htop maintains its setting in this config file: ~/.config/htop/htoprc.

Example

$ head ~/.config/htop/htoprc
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=0 48 17 18 38 39 40 2 46 47 49 1 
sort_key=46
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=0
show_thread_names=0
...

You could manipulate this file, htop makes no provisions for loading alternate files, so you'd have to beware of changing the file. You could also maintain your own file on the side, and then link to it prior to launching htop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.