Reputation: 3066
I want to count the CPU usage approximately but I don't want to use accton or any other software. Just only script. Can I use top to get the topmost CPU usage or memory usage's process name? When I use top -b I get a lot of unuseful information.
Upvotes: 2
Views: 593
Reputation: 97968
For cpu usage:
ps -eo comm,%cpu --no-headers | sort -k2 -nr | head -1
For memory:
ps -eo comm,%mem --no-headers | sort -k2 -nr | head -1
Upvotes: 1