3

Is it possible to monitor processes of multiple (but not all) users in Linux using top?

Something of this kind:

top -u user1 -u user2 
2
  • this (unix.stackexchange.com/questions/188702/…) may help you if you know the processes, but -u switch according to manual is exclusive - you can try to join by running a top in batch mode and out put to files and combine them or so, but no direct way I think. Commented Jul 10, 2018 at 14:22
  • Unfortunately, I do not know the processes in advance. The manual only says that 'p', 'u', and 'U' are mutually exclusive. That means that one can not do: 'top -u user1 -U user2". The manual does not say that there can not be 2 'u' options, for example. In fact, one can monitor multiple PIDs, e.g. "top -p 777 -p 888", even though 'p' is on the 'mutually exclusive" list. I am guessing that multiple -u options are simply not implemented (yet) in top. Commented Jul 10, 2018 at 14:36

2 Answers 2

1

My suggestion is to run the top command using the u options, either in different tabs, or different terminals (that way you could get what you are asking for in an organized way). The top command doesnt offer that option, so the only other way would be to filter the top output with the two "usernames" you want to show.

0

Alternativelly and as a work around, you can run

top | grep username 

Say that I have two user : tomcat1 and tomcat2

top | grep tomcat 

and it will show:

30243 tomcat1 20 0 9702832 5.1g 25192 S 0.7 32.8 871:07.12 java 16279 tomcat2 20 0 11.9g 5.4g 13508 S 0.3 34.9 99:03.34 java 
1
  • top becomes non-interactive after grep, so almost useless.. grep would work well with ps, pstree etc Commented Jan 8 at 11:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.