Linux view the number of processes and threads

Source: Internet
Author: User

1. View the process: Ps-ef or Ps-aux

Get the PID of the process:
such as:PSgrepgrep"grep"awk'{print $ 2}'

2. Query According to the process number:

# pstree-p Process Number

# TOP-HP Process Number

3. Query According to the process name:

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

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

4. View the number of threads

Need to get the PID of the thread

View all threads of a process #PSMp6648-o thread,tiduser%CPU PRI SCNT wchan USER SYSTEM tidroot0.0-    - -         -      -     -Root0.0   -- -         -      -6648Root0.0   +- -         -      -6650Root1.0   -- -         -      -14214Root0.0   at-Futex_--14216Root0.0   A-184466-      -15374Root0.0   at-184466-      -15376Root0.0   at-184466-      -15378Root0.0   at-184466-      -15380Root0.0   at-184466-      -15392Root0.0   at-184466-      -15394Root0.0   at-184466-      -15398View All child processes: # Pstree-P6648Agent_executor (6648) ─┬─Tar(15601) ───gzip(15607) ├─{agent_executor} (6650) ├─{agent_executor} (14214) ├─{agent_executor} (14216) ├─{agent_executor} (15374) ├─{agent_executor} (15376) ├─{agent_executor} (15378) ├─{agent_executor} (15380) ├─{agent_executor} (15392) ├─{agent_executor} (15394) └─{agent_executor} (15398)

5. Process start time (how long it takes to run)

Ps-eo Lstart Start-up time

Ps-eo ETime How long it takes to run.

Ps-eo Pid,lstart,etime | grep 5176

Explanation of ========================================PS aux or lax output =========================2,PS  %cpu%mem VSZ RSS TTY STAT START time Commanduser: Process owner PID: Process ID%CPU: CPU usage %MEM: occupied Memory usage vsz: Virtual memory size consumed RSS: Memory size used TTY: Terminal's secondary appliance number (minor device numbers of TTY) STAT: Process state: Start: Time when the process was started; time: The process consumes the CPU; COMM And: The name and parameters of the command;

Linux view the number of processes and threads

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.