[gllug] ps oddities

Nix nix at esperi.org.uk
Thu Mar 24 11:02:06 UTC 2005


On Wed, 23 Mar 2005, Steve Nelson suggested tentatively:
> Hello All,
> 
> I'm trying to understand why the output of ps differs so much when
> using the Unix98 options and BSD options.

Because ps tries to look like you'd `expect' it to look, and BSD
and SysV ps display different columns by default.

Note that procps-3.x have a *hugely* powerful ps and top with vast
numbers of options: the manpage rewards perusal (although the top
manpage is written in such a grating style that it might drive you
insane first).

e.g. have a sample .toprc:

RCfile for "top with windows"		# shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
cpu	fieldscur=AEHIOQPTWKNMXbcdfgjlrsuvyz
	winflags=64944, sortindx=10, maxtasks=0
	summclr=3, msgsclr=2, headclr=1, taskclr=2
tme	fieldscur=ABCefGjlrstuvyzMKNHIWopQDX
	winflags=64824, sortindx=12, maxtasks=0
	summclr=3, msgsclr=2, headclr=1, taskclr=2
mem	fieldscur=ANOPQRSTUVXbcdefgjlmyzWHIK
	winflags=64824, sortindx=13, maxtasks=0
	summclr=3, msgsclr=2, headclr=1, taskclr=2
usr	fieldscur=DEFGABXchijlopqrstuvyzMKNW
	winflags=64952, sortindx=4, maxtasks=0
	summclr=3, msgsclr=2, headclr=1, taskclr=2

Start top. Hit _. Boggle. :)


I find `ps -FTC some-command' very useful these days: the -O option
is nice, too, being the same as -o with a bunch of predefined
columns.

ps --forest is also nice, obsoleting pstree.

> Here are example processes genereated by ps ax:
> 
> 7098 ?        S      0:00 /local/netiq/UnixAgent/../jre/bin/java -Djava.netiq.h
> 8045 ?        S      0:00 /local/SiteScope/java/bin/exe/java -Xmx96m -Dsun.net.
> 31882 pts/1    S      0:04 /usr/j2sdk1.4.2_03/bin/java -Djava.awt.headless=true
> 
> However, ps -ef doesn't show the netiq processes.  As a result we see
> quite different results thus:

That's strange. I don't see this on any of my systems (running procps-3.2.5). A bug in your ps?

> # ps -ef | grep -ic java
> 146
> # ps ax | grep -ic java
> 191

Why do that when you can do

ps -fC java

> For reference, this is RHAS 2.1, procps version 2.0.7

Wow! That procps is known buggy and ancient (although I'm not sure if
this is one of the known bugs). Upgrade it and all should be well. :)

-- 
This is like system("/usr/funky/bin/perl -e 'exec sleep 1'");
   --- Peter da Silva
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list