2

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.

4

1 回答 1

1

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
于 2012-10-24T08:06:38.933 回答