View the CPU cores of a specified process in CentOS

Source: Internet
Author: User
Multiple multi-core CPUs are now the mainstream servers. many applications, such as Squid and nginx, have the ability to distribute processes or threads to different CPU cores. How can we view the distribution of different processes in the CPU core. Here we use the top tool and use the pgrep or pidof command to view the distribution of CPU cores in the nginx process, for example, top-p $ (pgrepnginx

Multiple multi-core CPUs are now the mainstream servers. many applications, such as Squid and nginx, have the ability to distribute processes or threads to different CPU cores.

How can we view the distribution of different processes in the CPU core.

Use the top tool and use the pgrep or pidof commands.

For example, to view the distribution of CPU cores in the nginx process:


  1. Top-p $ (pgrep nginx | awk 'In in {ORS = ","} {print $0} '| sed's/. $ //')
  2. # Or you can use
  3. # Pidof nginx | sed-e's //,/g'
  4. # To replace
  5. # Pgrep nginx | awk 'In in {ORS = ","} {print $0} '| sed's/. $ //'
  6. # To obtain the formatted pid value

 

Press the f key to list the display menu options, Press j, and select the CPU core information column. Press enter to return to the top screen.

As follows:


  1. Top-14:46:21 up, 2 users, load average: 0.00, 0.00, 0.00
  2. Tasks: 5 total, 0 running, 5 sleeping, 0 stopped, 0 zombie
  3. Cpu (s): 0.0% us, 0.1% sy, 0.0% ni, 99.9% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st
  4. Mem: 1026684 k total, 887572 k used, 139112 k free, 135308 k buffers
  5. Swap: 2064376 k total, 0 k used, 2064376 k free, 603008 k cached
  6.  
  7. Pid user pr ni virt res shr s % CPU % mem time + P COMMAND
  8. 12393 root 18 0 41000 1428 808 S 0.0 0: 00. 00 1 nginx
  9. 12625 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 0 nginx
  10. 12626 nginx 15 0 41344 1592 688 S 0.0 0: 00. 00 1 nginx
  11. 12627 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 2 nginx
  12. 12628 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 3 nginx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.