When it comes to server resources it’s important to pinpoint which process of which user consumes the most CPU or memory at a certain stage. For this, a dynamic list of processes and their used CPU and memory would be very nice to see while performing website testing.
This is quite easy to achieve using this command:
watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pcpu | head -20'
This will display the 20 processes that consumes the most CPU in descending order
Or, if you need only top 10 most memory intensive processes use this one:
watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem | head -10
This list updates every one second – this could be changed as well using the “-n 1” parameter.