Linux下查看进程线程数的方法

1,top -H -p ${pid}
或者 top -p ${pid} 然后 shit + H

top -H -p 4705

top - 14:43:48 up 180 days, 22:12, 1 user, load average: 0.19, 0.14, 0.14
Threads: 3 total, 0 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 16269088 total, 9349604 used, 6919484 free, 161692 buffers
KiB Swap: 16777212 total, 0 used, 16777212 free. 6798824 cached Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4705 1010 20 0 1005708 334820 1728 S 0.3 2.1 4746:49 redis-server
4707 1010 20 0 1005708 334820 1728 S 0.0 2.1 0:00.00 redis-server
4708 1010 20 0 1005708 334820 1728 S 0.0 2.1 0:00.00 redis-server

2,cat /proc/${pid}/status
其中Threads后面跟的就是线程数。


Linux下查看进程线程数的方法_第1张图片
1517465669.png

或者 ls /proc/${pid}/task

ls /proc/4705/task

4705 4707 4708

3,pstree -p ${pid}

pstree -p 4705

redis-server(4705)─┬─{redis-server}(4707)
└─{redis-server}(4708)

4,ps -hH -p ${pid}

ps -hH -p 4705

4705 ? Ssl 4746:23 /home/lobby-1-nearby-redis/bin/redis-server *:8379
4705 ? Ssl 0:00 /home/lobby-1-nearby-redis/bin/redis-server *:8379
4705 ? Ssl 0:00 /home/lobby-1-nearby-redis/bin/redis-server *:8379

你可能感兴趣的:(Linux下查看进程线程数的方法)