linux check the number of threads of a process

Take viewing mysql as an example

to get the pid of mysql

> netstat -anp|grep "mysql"
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      14108/mysqld


method one:
> cat /proc/14108/status
Name:   mysqld
State:  S (sleeping)
Tgid:   14108
Pid:    14108
PPid: 13824
TracerPid:      0
Uid:    497     497     497     497
Guide: 501 501 501 501
Expenditure: 0
FDSize: 256
Groups: 501
VmPeak:  1146932 kB
VmSize:  1146928 kB
VmLck:         0 kB
VmHWM:     95632 kB
VmRSS:     95628 kB
VmData:  1106984 kB
VmStk:        88 kB
VmExe:      8788 kB
VmLib:      3652 kB
VmPTE:       356 kB
VmSwap:        0 kB
Threads:        18
......


Method Two:

> ls /proc/14108/task/|wc -l
18


Method three:

> ps hH -p14108|wc -l
18

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326125270&siteId=291194637