LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-25-2007, 11:24 AM   #1
joepgjm
LQ Newbie
 
Registered: Apr 2007
Posts: 4

Rep: Reputation: 0
top and ps commands show incorrect pids


I am having problems with "top" and "ps" commands in Linux not showing the same pids. A "top" will show many (duplicate) pids but when I issue a "ps" on the pid it does not display or show up.

OS: 2.4.21-47.0.1.ELsmp
Box: Dell 1950/2900k
procps: procps-2.0.17-13.10

Help!
Thanks.
 
Old 04-25-2007, 11:35 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
Try adding "-m" flag to your ps. The -m tells it to show all threads - this is default in later versions but I ran into a system once that didn't show them and the -m did it for me.
 
Old 04-25-2007, 12:04 PM   #3
joepgjm
LQ Newbie
 
Registered: Apr 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks..this actually answered my question. I had assumed that top was at fault but including "-m" in "ps" revealed to me that there were processes not being displayed.

Question, if you can answer it.
In my case I am only supposed to be running 4 instances of a process. Why would there be 64 instances.

#ps -eaf | grep hosthan | wc -l = 4
#ps -eafm | grep hosthan | wc -l = 64


Thanks,
Joe.

Faith is as an illogical belief in the occurrence of the improbable. Imagining the Creator as a low comedian...at once the world becomes explicable.
 
Old 04-25-2007, 12:23 PM   #4
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
Because in Linux they show all "threads" as "processes" (unlike UNIX which shows only processes and requires other tools to look at threads). So what you're actually seeing is multiple "threads". This has to do with the way the Linux community chose to deal with the NPTL (Native Posix Thread Library).

If you had to use the -m it means you, like me, have a server that has an older procps package that didn't do this by default. It doesn't really change anything except the way it displays.

If they are threads they are using the same memory map (/proc/<pid>/maps). When I looked at this in the past I saw it mainly for a couple of Java things. By looking at the process name I was able to identify all the pids (using the -m) then find that there were real "processes" with different maps. All the other "processes" had the same maps as one of the above.

The main reason this becomes important is the way it is viewed would make you think the process is using more CPU and Memory than it really is if you summed up all the "processes". By doing the above exercise I was able to confirm that the memory maps were the same so it was only uses the total for one rather than the total for all.
 
  


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
incorrect iptables commands? devel Linux - Networking 3 06-02-2005 10:35 PM
What do you think are the top ten UNIX/LINUX commands marigb Linux - Newbie 24 05-17-2004 03:17 AM
poll: What do you think are Unix/Linux top ten most used commands marigb Linux - Newbie 0 05-11-2004 12:23 PM
top don't show me all my ram Polyvore Linux - General 2 04-29-2004 03:00 AM
Why does top show RAM almost all used up Apollo77 Linux - General 10 12-30-2003 04:48 PM


All times are GMT -5. The time now is 08:47 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration