Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.