10-22-04 12:49 PM
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
[ Post a follow-up to this message ]
|