Operating System - HP-UX
1826414 Members
4154 Online
109692 Solutions
New Discussion

Re: ps -C not returning process

 
SOLVED
Go to solution
Jonathan Fife
Honored Contributor

ps -C not returning process

I recently migrated a database to a new server running 11iv1, and one of my nightly scripts stopped working.

After some research, it turns out that the ps -C command isn't working the way I believe it should. I am testing to see if a process named ora_pmon_mx1bprd is running:

$ UNIX95= ps -C ora_pmon_mx1bprd
PID TTY TIME CMD
$

However, from everything else I can see it should be returning a process:

$ ps -ef | grep ora_pmon_mx1bprd
oracle 3436 1 0 Apr 15 ? 0:18 ora_pmon_mx1bprd
$ UNIX95= ps -f -p 3436
UID PID PPID C STIME TTY TIME CMD
oracle 3436 1 0 Apr 15 ? 00:18 ora_pmon_mx1bprd

Quoting ora_pmon_mx1bprd didn't help. Oracle is obviously renaming the command when it executes, but I don't believe that should be tripping up ps, and this works fine on my other servers (all running 11iv1). Anyone else ever seen something like this?

I know I can rewrite the script to use ps and grep to get the results, but ps -C is much cleaner, and I'm concerned that this might be just a symptom of a deeper problem.
Decay is inherent in all compounded things. Strive on with diligence
11 REPLIES 11
Peter Godron
Honored Contributor

Re: ps -C not returning process

Jonathan,
have you tried:
UNIX95=1 ps -C ora_pmon_mx1bprd
Peter Godron
Honored Contributor

Re: ps -C not returning process

Jonathan,
have you also tried:
UNIX95=ps -C ora_pmon_mx1bprd -o pid=
Jonathan Fife
Honored Contributor

Re: ps -C not returning process

Peter, thanks for your replies.

Unfortunately, neither of those commands returned the running process.

Decay is inherent in all compounded things. Strive on with diligence
Patrick Wallek
Honored Contributor

Re: ps -C not returning process

There is apparently something unique about the ora_pmon_ programs. I've tried on one of my oracle systems and it's behaving the same way.
Jonathan Fife
Honored Contributor

Re: ps -C not returning process

Patrick, that is a bit of a relief. Since this is a new rp4440 we just cut into production, I was pretty concerned that this might indicate some deeper, uglier issues.

I'm still confused as to why the ps -C works fine for the oracle processes on my other systems, but it is good to know that it's not just me.

If anyone has a solution (or has identified the cause) I would be interested, otherwise I'll just rewrite my script to use grep and pass it off as an anomaly.
Decay is inherent in all compounded things. Strive on with diligence
Ralph Grothe
Honored Contributor

Re: ps -C not returning process

Hm, with our instances this works.

e.g.

$ uname -srv; UNIX95= ps -C ora_pmon_ALMA
HP-UX B.11.11 U
PID TTY TIME CMD
6809 ? 00:21 ora_pmon_ALMA


It says that the xpg4 -C option of ps only parses the basename of the command.
However, this even works if I include args,
provided space is quoted.
Since the pmon proc doesn't appear with args let me demonstrate with the listener proc.

e.g.

$ UNIX95= ps -C tnslsnr -o comm,args
COMMAND COMMAND
tnslsnr /app/oracle/product/9.2.0/bin/tnslsnr l_alma -inherit

$ UNIX95= ps -C tnslsnr\ l_alma -o comm,args
COMMAND COMMAND
tnslsnr /app/oracle/product/9.2.0/bin/tnslsnr l_alma -inherit

I suppose you require the PID (maybe for dummy signalling?, e.g. kill -0).
How about slightly modifying your parsing?

e.g.

$ UNIX95= ps -u oracle -o pid= -o comm|awk '$2~/^ora_pmon/{print$1}'
6809


or use the Proc::ProcessTable CPAN module

e.g.

$ perl -MProc::ProcessTable -e 'print map $_->pid."\n", grep $_->cmndline =~ /^ora_pmon/, @{Proc::ProcessTable->new->table}'
6809





Madness, thy name is system administration
Jonathan Fife
Honored Contributor

Re: ps -C not returning process

Thanks, Ralph. I just rewrote my script to use ps -ef | grep. I actually don't need anything from the ps output, I am just testing to see that the instance is up before running some SQL.

I did find something interesting, though -- if I do:
$ UNIX95= ps -C oracle
it successfully returns all processes spawned from the $ORACLE_HOME/bin/oracle executable, even though they have been renamed to pmon, lgwr, or whatever. This suggests that my problem has something to do with the oracle process renaming itself after being forked.

I the same ps (and Oracle) patches on all my servers, so I really don't know why some would work and some wouldn't.

I'll keep the thread open in case anyone has additional input...
Decay is inherent in all compounded things. Strive on with diligence
Sandman!
Honored Contributor
Solution

Re: ps -C not returning process

Seems like it happens only for those processes that have more than twelve characters displayed under the CMD name column. The only way I'm able to see all pmon processes irrespective of how long their names are by using:

UNIX95=1 ps -C oracle -o comm,args | grep -i pmon

are you running into a similar problem?
Court Campbell
Honored Contributor

Re: ps -C not returning process

I too noticed this behavior. It seems if the the command is longer that 14 characters total it doesn't print.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Jonathan Fife
Honored Contributor

Re: ps -C not returning process

Bingo! It appears it is related to the string length. I had never run into that before.

Thanks for the info, Sandman and Court!
Decay is inherent in all compounded things. Strive on with diligence
Jonathan Fife
Honored Contributor

Re: ps -C not returning process

The command I was searching for was too many characters.

Thanks, everyone, for the help!
Decay is inherent in all compounded things. Strive on with diligence