I'm in AIX node and sometimes listener process from an oracle instance gets duplicated, i mean that it get spawned a second listener process. As we can't apply changes to the databases on this months, i want to build a shell that can identify the second listener (when it appears) and kill it.
In this node there are four oracle 10g instances. The problem with the second listener is don't allow external connections. That problem is a bug for the version 10.2.0.2.
I can't make changes to the databases, but what i can do is build a shell to identify when a second listener process is running (every 10 minutes) but i don't know how to do it.
How do i know when is a second listener process? I received from ussers the errors on external connections, so i connect to the node (AIX 64-bits) and make a ps -fea|grep tns, where i found two listener process. So i kill one of them (the newest).
What i want is automatize that. Can you help me? Thanks!
Just want to be sure of the order of fields in your "ps" and whether the main Listener is correctly started in background and therefore has a PPID of 1 . Also looking for a "ps" command which is less likely to give accidental matches.
Do you take your databases (and listener) down at night for backup? If so, consider what commands might be visible in memory at the time (and which we don't want to kill).
At this time, there is not a duplicate listener, and if occured i'll take a screenshot. But usually whe there is a second listener is below the onde who appears in the ps detailed above, with recent date and time, so that's the one i want to kill, when it appears, obviously.
You probably need something like this. Test throughly before removing the "echo" and be careful about running this when the system is starting or stopping the listener normally.
ps -fu oracle10 | grep "tnslsnr" | grep -v "grep" | awk '{print $2,$3}' | \
while read pid ppid
do
if [ $ppid -eq 1 ]
then
continue
fi
echo kill ${pid}
done