Is there any command in Linux to figure out, given a process, which processor the process is running? I am interested in figuring out the CPU busy and CPU idle time of that processor.
Linux Command to Find Processor Number for a Process
cpucpu usagelinuxprocess
Best Answer
You can use the
ps
command to query and display the active processor. For example, you might run:The
PSR
column shows thatinit
is running on processor 1 andps
is running on processor 0. See the manpage for ps(1) for more details on how to customize the fields that are displayed.You can configure a graphical tool like
htop
to display the current active processor. Also,htop
has a per-CPU load display graph, which may be what you're looking for. See, for example, the following screenshot from http://htop.sourceforge.net/.Finally, you can use the
taskset
tool to force affinity to a particular CPU.