[SunHELP] Getting PIDs

Leslie V Brigance sunhelp at sunhelp.org
Wed Nov 14 11:06:15 CST 2001


U might also consider a grep -v of the 1st PID within the string.
Assuming your file is  "jpid_file"

pgrep java |grep -v `cat jpid_file` | sort -n | tail -1

If U have several processes you need to record PIDs on, you will have to
build an iterative loop
as you process the growing file. It is possible that you would hit the max
number on your process ID
so the next PID would be a much lower number than your last recorded PID.
(At least that's the way my luck always runs)

Les


Hello,

Try the  -n option
it should get you the last one.

For some other order try using the sort command.
eg
  pgrep java | sort -n | tail -1

HTH
Tze Weng Foong

-----Original Message-----
From: Ben Ricker [mailto:bricker at wellinx.com]
Sent: Wednesday, 14 November 2001 7:03 AM
To: Sun Help List
Subject: [SunHELP] Getting PIDs


I have a problem. I administer a Web app that is run through a JVM on
Solaris. We are moving to a failover mod where there will be multiple
JVMs running on one machine. The problem I am having is loggin the PIDs
of the processes. Before, I would start the JVM, sleep for 5 seconds,
the pgrep for 'java' and write the returned PID to a file. Now that
there are two JVMs, both PIDs are being written to the file! I tried
separating them out but no joy.

I am able to get the first JVMs PID written to a file. It is when I exec
the second JVM that I get both PIDs written because there are two JVMs
running. I thought I could do some sort of compare of the two PIDs
returned to the file and only write the sequentially later PID, but I am
uncertain how to do that. Any direction would be most appreciated.

Ben Ricker
System Administrator
Wellinx.com



_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp





More information about the SunHELP mailing list