Command for finding process using too much CPU

39,718

Solution 1

Or using a few other utils you could do:

ps aux | sort -rk 3,3 | head -n 5

Change the value of head to get the number of processes you want to see.

Solution 2

Try doing this :

top -b -n1 -c 

And if you want the process that takes the most %CPU times :

top -b -n1 -c  | awk '/PID *USER/{print;getline;print}'

or

top -b -n1 -c  | grep -A 2 '^$'
Share:
39,718
user1136342
Author by

user1136342

Updated on July 22, 2022

Comments

  • user1136342
    user1136342 almost 2 years

    What command can I use to find a process that's using a lot of CPU? Can I do this without installing something new?

  • Thomas
    Thomas almost 8 years
    On my system, the last two commands consistently give me top as the command using the most CPU :)
  • mVChr
    mVChr about 7 years
    This can just be ps aux --sort=-pcpu | head -n5 but if you want to use sort you should include the -n (numeric) option otherwise 6.5 will be higher than 32.5. Otherwise, thanks!