Exclude a process from being listed in `top`

monitoringperformance-monitoringprocesstop

Is it possible to exclude some processes from being reported by top?

For example, I would like to exclude itself from its listing (ie, I don't want top to show in the process list).

I would also like to be able to exclude processes that do not belong to the user running top (except for root).

Is this possible? If so, how? If not, is there a similar tool that will do what I want (that does not involve running something like ps frequently).


I realize that you can monitor just a given user's processes by invoking with the -u or -U options, but that's not the same as monitoring only processes owned by the user running top.

Best Answer

Top gets its information directly from the /proc filesystem which is "dummy" filesystem dynamically generated by the Linux kernel.

Therefore hiding specific processes (such as itself) is only possible if

  1. You write a kernel module that hijacks the /proc fs
  2. You modify the source code of top application (user level code)

If you want complete control over what is visible you should write a script/program yourself that reads /proc.

I suggest that you explore /proc a bit more. You might get away with a simple grep/cat/awk script that does what you want.