Linux: command to find out number of cores the process is running on at any instance

08
2014-07
  • Ashish singhi

    This question already has an answer here:

  • Answers
  • Deven

    Top command can provide information on individual threads of a process using the following command

    top -H -p <pid>
    

    To find the last core on which the thread was run try press f, than press j to enable the CPU core column.

    Output will be like

    top - 11:50:35 up 332 days, 16:31,  2 users,  load average: 1.39, 1.45, 1.31
    Tasks:   7 total,   1 running,   6 sleeping,   0 stopped,   0 zombie
    Cpu(s):  2.8%us,  1.7%sy,  0.0%ni, 95.5%id,  0.0%wa,  0.0%hi,  0.1%si,  0.0%st
    Mem:  65980588k total, 24549232k used, 41431356k free,    30268k buffers
    Swap: 135170856k total, 23016712k used, 112154144k free, 11289596k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+   P COMMAND
    10721 tom       25   0  326m 285m 3536 R 100.0  0.4 182:13.73 22 kproxy
    10722 tom       17   0  326m 285m 3536 S  0.0  0.4   0:00.00  0 kproxy
    10723 tom       15   0  326m 285m 3536 S  0.0  0.4   0:00.15  7 kproxy
    10724 tom       15   0  326m 285m 3536 S  0.0  0.4   0:00.00  1 kproxy
    10722 tom       17   0  326m 285m 3536 S  0.0  0.4   0:00.00  0 kproxy
    10723 tom       15   0  326m 285m 3536 S  0.0  0.4   0:00.15  7 kproxy
    10724 tom       15   0  326m 285m 3536 S  0.0  0.4   0:00.00  1 kproxy
    

    Numbers below the P column is the core that was last used by the thread. Value R below the S column means that thread is running.


  • Related Question

    login - If I log out of a linux ssh shell, is there any way to jump back into a process that was running?
  • Jordan Reiter

    Possible Duplicate:
    Linux process to background - relogin - how to bring process back to foreground?

    Okay, kind of a weird question but let's say I'm running a long-running batch script in a terminal window and I close that terminal window.

    Is it possible, in any way, to ssh back into that server and run a command that pops you back into that process, so you can see it running again?

    This is on linux (Redhat).

    Thanks


  • Related Answers
  • Journeyman Geek

    you'd want to run the process in screen, most likely, then detach the screen session.

    I also think you can switch a process to the background with an && at the end of the line invoking it, and using fg n where n is the process number to bring it back to the front, though i haven't tried this yet.