View the number of threads in a process under Linux (GO)

Source: Internet
Author: User

Transferred from: https://www.cnblogs.com/caosiyang/archive/2012/10/15/2724585.html

There are times when it is necessary to do how many threads are currently running inside the process, so here are a few ways to use it.

1. Query According to the process number:

# pstree-p Process Number

# TOP-HP Process Number

2. Query according to the process name:

# pstree-p ' ps-e | grep Server | awk ' {print '} '

# pstree-p ' ps-e | grep Server | awk ' {print '} ' | Wc-l

This takes advantage of pipeline and command substitution,

I learned about command substitution today, which means that commands that are enclosed are prioritized and then output as arguments to other commands.

The above is with Ps-e | grep Server | The output (process number) of awk ' {print '} ' as a parameter to the PSTREE-P

The difference between pipeline and command substitution is:

Pipe: Pipe Symbol "|" Output from the left command as input to the right command

Command substitution: The output of the command in the command substitution "'" as a parameter for the corresponding location of the other command

View the number of threads in a process under Linux (GO)

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.