How to count process threads in Linux

You have a process that forks multiple threads? Here is how you can check how many threads it actually uses at the moment:

ps -T -p process_id

For example if you have an MySQL server running and you want to see how many threads it has spawn, you first need to get the main process id:

service mysql status

This shows you something like the following information:

mysql start/running, process 55291

So if you now do:

ps -T -p 55291

You’ll find all the sub processes spawned by the MySQL server

Leave a Reply

Your email address will not be published. Required fields are marked *