Get a refreshing list of running specific processes

I want to monitor running python processes with VSZ, RSS %MEM, %CPU etc. One of my priorities is a list refreshing every X seconds. I managed to come to the point of obtaining a refreshing list of processes using ps and watch

ps ax | grep python | awk '{print $1}' | xargs watch -n 15 ps u -p

That command simply find all the processes which includes python in its command line in ps and pass the pid values to watch.

ps u -p 9221 10186 11640 12347 14076 14263 14317 19029 22099 24278 26161 32469

It is all fine, but that command evaluates the pid list only once and keep watching those pids. What I need is executing ps ax | grep python command every X seconds and get a fresh list of running processes. That Way, I can see which process has started and which one had finished executing.

Asked By: FallenAngel

||

You can watch any command so give this a try

watch "ps aux | grep python"

Answered By: coteyr

You can also use top instead of watch:

top -p $(ps ax | grep python | awk '{print $1}' | paste -sd "," -) -d 2
Answered By: ErrieR
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.