Linux - How to find which process using processor, Find process on which processor

How to find which process using processor

In practicle we say that the serve has more processor. Like it has three five processor, ten processor etc. But at time we might need to figure it out that which process is running on which processor. A process and its id can be found using ps command.

Command to find number of processor in server
# grep processor /proc/cpuinfo
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
processor       : 8
processor       : 9
processor       : 10
processor       : 11
processor       : 12
processor       : 13
processor       : 14
processor       : 15

We can use ps command to find which process is using or executiong on which processor. In ps command -o can be used to specify the option's. Option sgi_p is used find out the processor that the process is currently executing on.
sgi_p  P  processor that the process is currently executing on. 
          Displays "*" if the process is not currently running or runnable.

Find which process on which processor
# ps -o %cpu,pid,ppid,sgi_p -u id825385
OUTPUT:
%CPU   PID  PPID P
 0.0  2918  2917 *
 0.0  3560  4989 *
 0.0  3577  3560 *
 0.0  3579     1 *
 0.0  4213  4207 *
 0.0  4214  4213 *
 0.0  4354  4214 1
 0.0  4987     1 *
 0.0  4989  4987 *
 0.0  8242     1 *
 0.0  8251     1 *
 0.0  8253     1 *

Find the process command and its processor
# ps -o comm,%cpu,pid,ppid,sgi_p -u id825385
OUTPUT:
 COMMAND         %CPU   PID  PPID P
 bash             0.0  2918  2917 *
 run-mozilla.sh   0.0  3560  4989 *
 firefox          0.0  3577  3560 *
 gconfd-2         0.0  3579     1 *
 totem            0.0  4213  4207 *
 bash             0.0  4214  4213 *
 ps               0.0  4355  4214 1
 vlc              0.0  4987     1 *
 Xvnc             0.0  8242     1 *
 vncconfig        0.0  8251     1 *

The topic on Linux - How to find which process using processor is posted by - Math

Hope you have enjoyed, Linux - How to find which process using processorThanks for your time

Tech Bluff