Unix administration - processes running

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > October 2004 > processes running





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author processes running
Demetris

2004-10-22, 7:49 am

Hello there!

I have the following command

ps -fu oracle | grep -v grep | grep ora_pmon_RCAT

which gives me the following result:

oracle 78608 1 0 15:22:04 - 0:00 ora_pmon_RCATPROD
oracle 93424 1 0 10:09:22 - 0:00 ora_pmon_RCAT

I want a command to give only the last process i.e
oracle 93424 1 0 10:09:22 - 0:00 ora_pmon_RCAT

I am trying to see if an Oracle database is running and I have two
databases with the name RCAT and RCATPROD.

If i give that ps command based on the ORACLE SID i get both processes
but i want only for example the RCAT process to
be displayed.

Any help will be appreciated.

Thanks
Stephane CHAZELAS

2004-10-22, 7:49 am

2004-10-22, 05:29(-07), Demetris:
[...]
> ps -fu oracle | grep -v grep | grep ora_pmon_RCAT
>
> which gives me the following result:
>
> oracle 78608 1 0 15:22:04 - 0:00 ora_pmon_RCATPROD
> oracle 93424 1 0 10:09:22 - 0:00 ora_pmon_RCAT
>
> I want a command to give only the last process i.e
> oracle 93424 1 0 10:09:22 - 0:00 ora_pmon_RCAT

[...]

if ps -u oracle -o comm= | grep -qx ora_pmon_RCAT; then
echo "There's a least 1 ora_pmon_RCAT"
else
echo "no ora_pmon_RCAT seems to be running"
fi

Depending on your system, you may also use pgrep, killall -s, ps
-C or pidof...

(if your grep doesn't have the -x or -q option, then change it
to grep -l '^ora_pmon_RCAT$' > /dev/null)

(if your ps doesn't have -o, then change it to:
ps -fu oracle | awk '$NF == "ora_pmon_RCAT" {n=1; exit}
END{exit(1-n)}'

(none tested).

--
Stephane
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com