LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2009, 01:28 AM   #1
haseit
LQ Newbie
 
Registered: Jan 2009
Location: Colombo / Sri Lanka
Posts: 14

Rep: Reputation: 0
Question Get Thread count , Used memory for a particular Process


Hello All,

I've several question related to the Process information gathering in Linux which use the "ps" functionality.

My problem is

1. How to get the Tread count for particular process name(or the command such as gedit,skype,eclipse)

eg: ps -elm|grep $pid|grep -v grep |wc -l

in this example it use the PID what i actually want is to get the thread count using the process name

2. How to get the memory size in MB for a given process name or PID using greap functionality such as in the above example.

3. How to search a process is exist or not using the given process name or PID using greap as above example.

4. How to find the main module which need to run the process name or PID using greap.

Please help me on this matter ......

Thank you in Advance
Hasantha
 
Old 02-25-2009, 02:24 AM   #2
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

Rep: Reputation: 32
what about your effort? what you tried?
 
Old 02-25-2009, 11:11 PM   #3
haseit
LQ Newbie
 
Registered: Jan 2009
Location: Colombo / Sri Lanka
Posts: 14

Original Poster
Rep: Reputation: 0
Hello Chakka,

I know the 1st one is quite ok but i'm struggling with other 2,3,4,5 problems i mention. if you know please help me on this in advance... Thanks

Hasantha
 
Old 02-25-2009, 11:14 PM   #4
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

Rep: Reputation: 32
for second question, check if top is helpful to you....

Last edited by chakka.lokesh; 02-25-2009 at 11:26 PM.
 
Old 02-25-2009, 11:25 PM   #5
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

Rep: Reputation: 32
Quote:
Originally Posted by haseit View Post
3. How to search a process is exist or not using the given process name or PID using greap as above example.
ps aux | grep <PID>

Note: this will print the process details if it is existing along with the command we used which is grep.

like the following:

[lokesh@computer ~]$ ps aux | grep 2338
lokesh 2338 0.1 0.3 4840 1524 pts/0 Ss 11:00 0:00 bash
lokesh 2371 0.0 0.1 4044 668 pts/0 R+ 11:01 0:00 grep 2338

if the process with id 2338 is not existing the the result will be like this.

[lokesh@computer ~]$ ps aux | grep 2338
lokesh 2371 0.0 0.1 4044 668 pts/0 R+ 11:01 0:00 grep 2338

Don't get confused.
 
Old 02-25-2009, 11:28 PM   #6
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

Rep: Reputation: 32
Quote:
Originally Posted by haseit View Post
4. How to find the main module which need to run the process name or PID using greap.
I didn't understand this question. can you please reframe this so that I will be able to try to give answer.
 
Old 02-26-2009, 01:50 AM   #7
haseit
LQ Newbie
 
Registered: Jan 2009
Location: Colombo / Sri Lanka
Posts: 14

Original Poster
Rep: Reputation: 0
Hello Chakka,

Thank you for the quick respond. really appreciate your effort.

for the 2nd Question i actually need to get the process memory size in MB look the below example m looking for

[lokesh@computer ~]$ ps aux | grep PID ...... something
20 MB ... or the size of the process

for the 4th Question what i want is to get the CMD for a particular process
EG: ps -ef .... something ..
usr/lib/libstdc++.so.6

(what i really need to get only the CMD)

so if i use that CMD value and execute i need to get a fresh application for that.

Thanks in advance again
Hasantha
 
Old 02-26-2009, 05:10 AM   #8
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

Rep: Reputation: 32
for your second question, i didn't found anywhere ps is giving direct memory details.


with respect to your fourth, what is this CMD? Do you mean command? If it is have a look at the last column of the ps aux command.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Process size and Thread count for a particular running process haseit Linux - Newbie 2 01-22-2009 11:09 PM
FreeRadius Total Thread Count limit ukursat Linux - Server 2 11-26-2008 02:05 PM
Thread subscription count Matir LQ Suggestions & Feedback 2 01-11-2006 10:07 AM
Getting thread count for proc in linux vladS Linux - General 2 03-31-2004 04:28 PM
%CPU , Memory Usage, Thread count srinivasar Programming 0 09-20-2003 03:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration