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.

link|improve this question
feedback

2 Answers

up vote 5 down vote accepted

You can use the ps command to query and display the active processor. For example, you might run:

$ ps -aF
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root         1     0  0  5971  1764   1 Sep15 ?        00:00:01 /sbin/init
ubuntu   28903  2975  0  3826  1208   0 09:36 pts/0    00:00:00 ps -aF

The PSR column shows that init is running on processor 1 and ps 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/.

htop screenshot

Finally, you can use the taskset tool to force affinity to a particular CPU.

link|improve this answer
feedback

Do you mean like top? It won't let you "figure out" the busy/idle time, but it does figure it out for you.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.