Search code examples
linuxprocessprocps

ps utility in linux (procps), how to check which CPU is used


It is about procps package, utility ps for linux.

Can it print the number of last used CPU for each process (thread)?

Update: Not a CPU Time (10 seconds), but a CPU NUMBER (CPU0,CPU5,CPU123)


Solution

  • which of multiple processors? it does not offer an option for that according to the manpage. but on my Debian stable system it accepts the undocumented -o cpu


    after looking at the source, and the output of ps L, I believe your answer is either the cpuid or sgi_p output options, column IDs CPUID and P, respectively.
    And 'cpu' should work according to this note in output.c, but it's currently tied to the 'nop' output pr_nop():

    {"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */