How to get all processes running on each CPU core in Ubuntu?

49,300

Solution 1

You can do that with ps -aeF, see the C column

UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0  2015 ?        00:08:07 /sbin/init

Or with htop, configure it to show the PROCESSOR column,

enter image description here

To set CPU affinity, you can use taskset command

Solution 2

Normal top can show the last used CPU, too.

You have to press f while viewing the main screen to enter the Fields Management screen, arrow down to P = Last Used CPU (SMP) and toggle it on with d or space. Press q or escape to return to the main screen.

You may want to move the P column up in the Fields Management screen if you don't like the P column on the far right of the output.

Share:
49,300

Related videos on Youtube

Rohanil
Author by

Rohanil

I am a self-taught Backend developer. My educational background is in Electrical Engineering. I did my specialization in Signal Processing which is equivalent to Data Processing. And from there, I got interest in software development. I have been working as a software developer for the more than 6 years. I worked with Python for the first 2 years. Then I got into Golang for 2 years. I have experience using various tools and frameworks. I have worked professionally using flask, postgresql, mongodb, docker, celery, kafka, influxdb, elasticsearch, git, jenkins, php, javascript, vuejs.

Updated on September 18, 2022

Comments

  • Rohanil
    Rohanil almost 2 years

    I am working on Ubuntu14.04 server and it has 48 CPU cores. I am seeing there is high CPU usage on one core from sar information. So I want to know which processes are running on that core. How should I get all processes running on each CPU core in Ubuntu?

  • Mike Pennington
    Mike Pennington about 4 years
    You said ps -aeF, but I had to remove a on our F5 LTM shell... ps -eF worked for me
  • dahohu527
    dahohu527 over 2 years
    This command is really helpful