温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux怎么查看线程

发布时间:2022-02-01 10:56:11 来源:亿速云 阅读:273 作者:小新 栏目:开发技术

这篇文章给大家分享的是有关Linux怎么查看线程的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

Linux系统的进程是由线程组成的,当然Linux进程下的线程数是不固定的,可以是一个进程,也可以是多个进程。

Linux怎么查看线程

pstree命令以树状图显示进程间的关系(display a tree of processes)。ps命令可以显示当前正在运行的那些进程的信息,但是对于它们之间的关系却显示得不够清晰。在Linux系统中,系统调用fork可以创建子进程,通过子shell也可以创建子进程,Linux系统中进程之间的关系天生就是一棵树,树的根就是进程PID为1的init进程。

1>.安装pstree命令行工具,包名为:“psmisc”

 [root@yinzhengjie bin]# yum -y install psmisc
 Loaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile
 Resolving Dependencies
 --> Running transaction check
 ---> Package psmisc.x86_64 0:22.20-15.el7 will be installed
 --> Finished Dependency Resolution
 
 Dependencies Resolved
 
 ====================================================================================================================================================================
  Package                               Arch                                  Version                                      Repository                           Size
 ====================================================================================================================================================================
 Installing:
  psmisc                                x86_64                                22.20-15.el7                                 base                                141 k
 
 Transaction Summary
 ====================================================================================================================================================================
 Install  1 Package
 
 Total download size: 141 k
 Installed size: 475 k
 Downloading packages:
 psmisc-22.20-15.el7.x86_64.rpm                                                                                                               | 141 kB  00:00:00    
 Running transaction check
 Running transaction test
 Transaction test succeeded
 Running transaction
   Installing : psmisc-22.20-15.el7.x86_64                                                                                                                       1/1
   Verifying  : psmisc-22.20-15.el7.x86_64                                                                                                                       1/1
 
 Installed:
   psmisc.x86_64 0:22.20-15.el7                                                                                                                                      
 
 Complete!
 [root@yinzhengjie bin]#

[root@yinzhengjie bin]# yum -y install psmisc

2>.相关参数介绍

 Usage: pstree [ -a ] [ -c ] [ -h | -H PID ] [ -l ] [ -n ] [ -p ] [ -g ] [ -u ]
               [ -A | -G | -U ] [ PID | USER ]
        pstree -V
 Display a tree of processes.
 
   -a, --arguments                       显示命令时候,并显示其参数的完整内容
 
   -A, --ascii                              各进程树之间的连接以ASCII码字符来连接
 
   -c, --compact                          取消同名兄弟进程的合并(默认会将同名的兄弟进程合并)
 
   -h, --highlight-all                    突出当前进程及其祖先
   -H PID,
 
   --highlight-pid=PID                   突出这个过程和它的祖先
 
   -g, --show-pgids                      显示进程组ID;
 
   -G, --vt100                             使用VT100线绘制字符
 
   -l, --long                             不要截断长线。
 
   -n, --numeric-sort                    用PID排序输出
   -N type,
   --ns-sort=type                        sort by namespace type (ipc, mnt, net, pid, user, uts)
 
   -p, --show-pids                       同时列出每个进程的PID
 
   -s, --show-parents                    显示选定过程的父母
 
   -S, --ns-changes                      显示命名空间转换
 •  -u, --uid-changes                     同时列出每个进程的所属账号名称
 
   -U, --unicode                           各进程树之间的连接以utf8字符来连接,某些终端可能会有错误
 
   -V, --version                           显示版本信息
   -Z,
   --security-context                     显示SELinux的安全上下文
 
   PID                                   从这个PID开始;默认值是1(init)。
 
   USER                                   只显示在该用户的进程中的树

3>.案例1-显示进程之间的关系

 [root@yinzhengjie bin]# pstree -apnh
 systemd,1 --switched-root --system --deserialize 22
   ├─systemd-journal,730
   ├─systemd-udevd,758
   ├─lvmetad,761 -f
   ├─auditd,1006
   │   └─{auditd},1007
   ├─irqbalance,1040 --foreground
   ├─systemd-logind,1041
   ├─polkitd,1043 --no-debug
   │   ├─{polkitd},1048
   │   ├─{polkitd},1051
   │   ├─{polkitd},1053
   │   ├─{polkitd},1054
   │   └─{polkitd},1055
   ├─dbus-daemon,1044 --system --address=systemd: --nofork --nopidfile --systemd-activation
   ├─NetworkManager,1046 --no-daemon
   │   ├─{NetworkManager},1072
   │   └─{NetworkManager},1074
   ├─crond,1047 -n
   ├─chronyd,1060
   ├─agetty,1065 --noclear tty1 linux
   ├─sshd,1400 -D
   │   ├─sshd,1985    
   │   │   └─bash,1987
   │   │       └─pstree,1660 -apnh
   │   └─sshd,2017
   │       └─bash,2019
   ├─tuned,1401 -Es /usr/sbin/tuned -l -P
   │   ├─{tuned},1706
   │   ├─{tuned},1707
   │   ├─{tuned},1708
   │   └─{tuned},1779
   ├─gmetad,1402 -d 1
   │   ├─{gmetad},1403
   │   ├─{gmetad},1404
   │   ├─{gmetad},1405
   │   ├─{gmetad},1406
   │   ├─{gmetad},1407
   │   ├─{gmetad},1408
   │   ├─{gmetad},1409
   │   └─{gmetad},1410
   ├─httpd,1411 -DFOREGROUND
   │   ├─httpd,1757 -DFOREGROUND
   │   ├─httpd,1758 -DFOREGROUND
   │   ├─httpd,1759 -DFOREGROUND
   │   ├─httpd,1760 -DFOREGROUND
   │   └─httpd,1761 -DFOREGROUND
   ├─rsyslogd,1414 -n
   │   ├─{rsyslogd},1421
   │   └─{rsyslogd},1427
   ├─zabbix_agentd,1418 -c /etc/zabbix/zabbix_agentd.conf
   │   ├─zabbix_agentd,1420          
   │   ├─zabbix_agentd,1422
   │   ├─zabbix_agentd,1423
   │   ├─zabbix_agentd,1424
   │   └─zabbix_agentd,1425  
   ├─gmond,1851
   │   └─{gmond},1855
   └─java,2484 -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp/soft/zk/bin/../build/classes:/soft/zk/bin/../build/lib/*.jar:/soft/zk/bin/../lib/
       ├─{java},2487
       ├─{java},2488
       ├─{java},2489
       ├─{java},2490
       ├─{java},2491
       ├─{java},2492
       ├─{java},2493
       ├─{java},2494
       ├─{java},2495
       ├─{java},2496
       ├─{java},2497
       ├─{java},2498
       ├─{java},2499
       ├─{java},2500
       ├─{java},2501
       ├─{java},2502
       ├─{java},2503
       ├─{java},2504
       ├─{java},2505
       ├─{java},2506
       ├─{java},2507
       ├─{java},2508
       ├─{java},2509
       ├─{java},2510
       ├─{java},2511
       ├─{java},2512
       ├─{java},2513
       ├─{java},2514
       ├─{java},2515
       ├─{java},2516
       ├─{java},2517
       ├─{java},2518
       ├─{java},2519
       ├─{java},2520
       ├─{java},2521
       ├─{java},2522
       ├─{java},2523
       ├─{java},2524
       ├─{java},2525
       ├─{java},2526
       ├─{java},2527
       ├─{java},2528
       ├─{java},2529
       ├─{java},2530
       ├─{java},2531
       ├─{java},2532
       ├─{java},2534
       ├─{java},2535
       ├─{java},2536
       ├─{java},2537
       ├─{java},2538
       ├─{java},2539
       ├─{java},2540
       ├─{java},2541
       ├─{java},2542
       ├─{java},2543
       ├─{java},2544
       ├─{java},2545
       ├─{java},2546
       ├─{java},2547
       ├─{java},2548
       └─{java},2549
 [root@yinzhengjie bin]#

[root@yinzhengjie bin]# pstree -apnh

4>.案例2-以树状图显示进程,还显示进程PID

 [root@yinzhengjie bin]# pstree -p
 systemd(1)─┬─NetworkManager(1046)─┬─{NetworkManager}(1072)
            │                      └─{NetworkManager}(1074)
            ├─agetty(1065)
            ├─auditd(1006)───{auditd}(1007)
            ├─chronyd(1060)
            ├─crond(1047)
            ├─dbus-daemon(1044)
            ├─gmetad(1402)─┬─{gmetad}(1403)
            │              ├─{gmetad}(1404)
            │              ├─{gmetad}(1405)
            │              ├─{gmetad}(1406)
            │              ├─{gmetad}(1407)
            │              ├─{gmetad}(1408)
            │              ├─{gmetad}(1409)
            │              └─{gmetad}(1410)
            ├─gmond(1851)───{gmond}(1855)
            ├─httpd(1411)─┬─httpd(1757)
            │             ├─httpd(1758)
            │             ├─httpd(1759)
            │             ├─httpd(1760)
            │             └─httpd(1761)
            ├─irqbalance(1040)
            ├─java(2484)─┬─{java}(2487)
            │            ├─{java}(2488)
            │            ├─{java}(2489)
            │            ├─{java}(2490)
            │            ├─{java}(2491)
            │            ├─{java}(2492)
            │            ├─{java}(2493)
            │            ├─{java}(2494)
            │            ├─{java}(2495)
            │            ├─{java}(2496)
            │            ├─{java}(2497)
            │            ├─{java}(2498)
            │            ├─{java}(2499)
            │            ├─{java}(2500)
            │            ├─{java}(2501)
            │            ├─{java}(2502)
            │            ├─{java}(2503)
            │            ├─{java}(2504)
            │            ├─{java}(2505)
            │            ├─{java}(2506)
            │            ├─{java}(2507)
            │            ├─{java}(2508)
            │            ├─{java}(2509)
            │            ├─{java}(2510)
            │            ├─{java}(2511)
            │            ├─{java}(2512)
            │            ├─{java}(2513)
            │            ├─{java}(2514)
            │            ├─{java}(2515)
            │            ├─{java}(2516)
            │            ├─{java}(2517)
            │            ├─{java}(2518)
            │            ├─{java}(2519)
            │            ├─{java}(2520)
            │            ├─{java}(2521)
            │            ├─{java}(2522)
            │            ├─{java}(2523)
            │            ├─{java}(2524)
            │            ├─{java}(2525)
            │            ├─{java}(2526)
            │            ├─{java}(2527)
            │            ├─{java}(2528)
            │            ├─{java}(2529)
            │            ├─{java}(2530)
            │            ├─{java}(2531)
            │            ├─{java}(2532)
            │            ├─{java}(2534)
            │            ├─{java}(2535)
            │            ├─{java}(2536)
            │            ├─{java}(2537)
            │            ├─{java}(2538)
            │            ├─{java}(2539)
            │            ├─{java}(2540)
            │            ├─{java}(2541)
            │            ├─{java}(2542)
            │            ├─{java}(2543)
            │            ├─{java}(2544)
            │            ├─{java}(2545)
            │            ├─{java}(2546)
            │            ├─{java}(2547)
            │            ├─{java}(2548)
            │            └─{java}(2549)
            ├─lvmetad(761)
            ├─polkitd(1043)─┬─{polkitd}(1048)
            │               ├─{polkitd}(1051)
            │               ├─{polkitd}(1053)
            │               ├─{polkitd}(1054)
            │               └─{polkitd}(1055)
            ├─rsyslogd(1414)─┬─{rsyslogd}(1421)
            │                └─{rsyslogd}(1427)
            ├─sshd(1400)─┬─sshd(1985)───bash(1987)───pstree(2403)
            │            └─sshd(2017)───bash(2019)
            ├─systemd-journal(730)
            ├─systemd-logind(1041)
            ├─systemd-udevd(758)
            ├─tuned(1401)─┬─{tuned}(1706)
            │             ├─{tuned}(1707)
            │             ├─{tuned}(1708)
            │             └─{tuned}(1779)
            └─zabbix_agentd(1418)─┬─zabbix_agentd(1420)
                                  ├─zabbix_agentd(1422)
                                  ├─zabbix_agentd(1423)
                                  ├─zabbix_agentd(1424)
                                  └─zabbix_agentd(1425)
 [root@yinzhengjie bin]#

[root@yinzhengjie bin]# pstree -p

5>.案例3-*显示命令和其完整参数*

 [root@yinzhengjie bin]# pstree -a
 systemd --switched-root --system --deserialize 22
   ├─NetworkManager --no-daemon
   │   └─2*[{NetworkManager}]
   ├─agetty --noclear tty1 linux
   ├─auditd
   │   └─{auditd}
   ├─chronyd
   ├─crond -n
   ├─dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
   ├─gmetad -d 1
   │   └─8*[{gmetad}]
   ├─gmond
   │   └─{gmond}
   ├─httpd -DFOREGROUND
   │   ├─httpd -DFOREGROUND
   │   ├─httpd -DFOREGROUND
   │   ├─httpd -DFOREGROUND
   │   ├─httpd -DFOREGROUND
   │   └─httpd -DFOREGROUND
   ├─irqbalance --foreground
   ├─java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp/soft/zk/bin/../build/classes:/soft/zk/bin/../build/lib/*.jar:/soft/zk/bin/../lib/
   │   └─62*[{java}]
   ├─lvmetad -f
   ├─polkitd --no-debug
   │   └─5*[{polkitd}]
   ├─rsyslogd -n
   │   └─2*[{rsyslogd}]
   ├─sshd -D
   │   ├─sshd    
   │   │   └─bash
   │   │       └─pstree -a
   │   └─sshd
   │       └─bash
   ├─systemd-journal
   ├─systemd-logind
   ├─systemd-udevd
   ├─tuned -Es /usr/sbin/tuned -l -P
   │   └─4*[{tuned}]
   └─zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
       ├─zabbix_agentd          
       ├─zabbix_agentd
       ├─zabbix_agentd
       ├─zabbix_agentd
       └─zabbix_agentd  
 [root@yinzhengjie bin]#

[root@yinzhengjie bin]# pstree -a

6>.案例4-取消合并,默认会将同名的兄弟进程合并,-c取消合并,分开显示

 [root@yinzhengjie bin]# pstree -c
 systemd─┬─NetworkManager─┬─{NetworkManager}
         │                └─{NetworkManager}
         ├─agetty
         ├─auditd───{auditd}
         ├─chronyd
         ├─crond
         ├─dbus-daemon
         ├─gmetad─┬─{gmetad}
         │        ├─{gmetad}
         │        ├─{gmetad}
         │        ├─{gmetad}
         │        ├─{gmetad}
         │        ├─{gmetad}
         │        ├─{gmetad}
         │        └─{gmetad}
         ├─gmond───{gmond}
         ├─httpd─┬─httpd
         │       ├─httpd
         │       ├─httpd
         │       ├─httpd
         │       └─httpd
         ├─irqbalance
         ├─java─┬─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      ├─{java}
         │      └─{java}
         ├─lvmetad
         ├─polkitd─┬─{polkitd}
         │         ├─{polkitd}
         │         ├─{polkitd}
         │         ├─{polkitd}
         │         └─{polkitd}
         ├─rsyslogd─┬─{rsyslogd}
         │          └─{rsyslogd}
         ├─sshd─┬─sshd───bash───pstree
         │      └─sshd───bash
         ├─systemd-journal
         ├─systemd-logind
         ├─systemd-udevd
         ├─tuned─┬─{tuned}
         │       ├─{tuned}
         │       ├─{tuned}
         │       └─{tuned}
         └─zabbix_agentd─┬─zabbix_agentd
                         ├─zabbix_agentd
                         ├─zabbix_agentd
                         ├─zabbix_agentd
                         └─zabbix_agentd
 [root@yinzhengjie bin]#

[root@yinzhengjie bin]# pstree -c

7>.案例5-查询zookeeper进程打开的线程数

 [root@yinzhengjie bin]# jps
 2484 QuorumPeerMain
 5127 Jps
 [root@yinzhengjie bin]#
 [root@yinzhengjie bin]#
 [root@yinzhengjie bin]# pstree -p `jps | grep QuorumPeerMain | awk '{print $1}'` | wc -l
 62
 [root@yinzhengjie bin]#
 [root@yinzhengjie bin]#
 [root@yinzhengjie bin]# pstree -p 2484 | wc -l
 62
 [root@yinzhengjie bin]#

总结:

  通过pstree清晰的看到进程的父子关系,但是进程状态查看,还是需要ps、top等命令。pstree命令是用于查看进程树之间的关系,即哪个进程是父进程,哪个是子进程,可以清楚的看出来是谁创建了谁。

  推荐学习的博客:http://www.runoob.com/linux/linux-command-manual.html

二.使用top命令查看

1>.使用pstree命令查看”ResourceManager”进程打开的线程数

 [root@yinzhengjie ~]# jps
 6178 Jps
 10339 ResourceManager
 10309 JobTracker
 9462 NameNode
 9464 Bootstrap
 9466 DFSZKFailoverController
 11052 HistoryServer
 11054 HistoryServer
 10367 JobHistoryServer
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]# pstree -p 10339 | wc -l
 248
 [root@yinzhengjie ~]#

2>.使用top命令查看“ResourceManager”打开的进程数

 [root@yinzhengjie ~]# top -H -p 10339
 top - 01:38:45 up 7 days,  1:33,  3 users,  load average: 0.02, 0.06, 0.05
 Threads: 247 total,   0 running, 247 sleeping,   0 stopped,   0 zombie
 %Cpu(s):  0.1 us,  0.0 sy,  0.0 ni, 99.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
 KiB Mem : 18328176 total, 11610648 free,  5253524 used,  1464004 buff/cache
 KiB Swap:  9306108 total,  9306108 free,        0 used. 12658008 avail Mem
 
   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                        
 10791 yarn      20   0 3131380 622256  23808 S  0.3  3.4   0:15.83 java                                                                                            
 10339 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.25 java                                                                                            
 10608 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:03.12 java                                                                                            
 10609 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.65 java                                                                                            
 10610 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.65 java                                                                                            
 10611 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.69 java                                                                                            
 10612 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.66 java                                                                                            
 10613 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.70 java                                                                                            
 10614 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.69 java                                                                                            
 10615 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.67 java                                                                                            
 10616 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.68 java                                                                                            
 10617 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.68 java                                                                                            
 10618 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.67 java                                                                                            
 10619 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.70 java                                                                                            
 10620 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.68 java                                                                                            
 10621 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.66 java                                                                                            
 10622 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.67 java                                                                                            
 10623 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:01.69 java                                                                                            
 10624 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10625 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10626 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10627 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10628 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:15.73 java                                                                                            
 10645 yarn      20   0 3131380 622256  23808 S  0.0  3.4   1:59.54 java                                                                                            
 10651 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.06 java                                                                                            
 10652 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.04 java                                                                                            
 10656 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10657 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:00.00 java                                                                                            
 10658 yarn      20   0 3131380 622256  23808 S  0.0  3.4   0:08.24 java                                                                                            
 [root@yinzhengjie ~]#

[root@yinzhengjie ~]# top -H -p 10339

Linux怎么查看线程

三.直接去“/proc”对应PID的status目录查看

由于在Linux操作系统中,正在运行的程序都会在/proc这个目录下存放运行时文件的状态信息,因此我们在这个目录下,找到对应的进程ID就可以查看到该进程打开的线程数。当然还有一些其他的详细信息都在这个目录下存放着。

 [root@yinzhengjie ~]# cat /proc/10339/status
 Name:   java
 Umask:  0022
 State:  S (sleeping)
 Tgid:   10339
 Ngid:   0
 Pid:    10339
 PPid:   8410
 TracerPid:      0
 Uid:    988     988     988     988
 Gid:    985     985     985     985
 FDSize: 512
 Groups: 985 994
 VmPeak:  3131384 kB
 VmSize:  3131380 kB
 VmLck:         0 kB
 VmPin:         0 kB
 VmHWM:    622300 kB
 VmRSS:    622256 kB
 RssAnon:          598448 kB
 RssFile:           23808 kB
 RssShmem:              0 kB
 VmData:  2962116 kB
 VmStk:       144 kB
 VmExe:         4 kB
 VmLib:     17152 kB
 VmPTE:      1808 kB
 VmSwap:        0 kB
 Threads:        248
 SigQ:   0/71498
 SigPnd: 0000000000000000
 ShdPnd: 0000000000000000
 SigBlk: 0000000000000000
 SigIgn: 0000000000000000
 SigCgt: 2000000181005ccf
 CapInh: 0000000000000000
 CapPrm: 0000000000000000
 CapEff: 0000000000000000
 CapBnd: 0000001fffffffff
 CapAmb: 0000000000000000
 Seccomp:        0
 Cpus_allowed:   fffff
 Cpus_allowed_list:      0-19
 Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000003
 Mems_allowed_list:      0-1
 voluntary_ctxt_switches:        67
 nonvoluntary_ctxt_switches:     19
 [root@yinzhengjie ~]#

[root@yinzhengjie ~]# cat /proc/10339/status

Linux怎么查看线程

四.*直接去“/proc”对应PID的task目录查看*

 [root@yinzhengjie ~]# jps
 8704 Jps
 10339 ResourceManager
 10309 JobTracker
 9462 NameNode
 9464 Bootstrap
 9466 DFSZKFailoverController
 11052 HistoryServer
 11054 HistoryServer
 10367 JobHistoryServer
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]# pstree -p 10339 | wc -l    
 248
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]# ll /proc/10339/task/ | wc -l    
 248
 [root@yinzhengjie ~]#
 [root@yinzhengjie ~]#

感谢各位的阅读!关于“Linux怎么查看线程”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI