Kill hanging listener processes
Case Study:
Scorfield is working in support team. He needs to kill Listener if the listener is in hung state at night when DBA’s are not available.
Solution:
Create a script that can kill the listener process and provide sudo access to scorfield to execute the script.
[root@stagedb3 ~]# vi /usr/local/bin/kill_listener.sh
#!/bin/sh
kill -9 `ps -ef|grep -v grep|grep LISTENER|grep oracle|awk '{print $2}'|xargs`
echo "Tried to kill Oracle listener(s), check with ps -ef if the process(es) died "
[root@stagedb3 ~]# chown oracle:dba /usr/local/bin/kill_listener.sh
[root@stagedb3 ~]# chmod 600 /usr/local/bin/kill_listener.sh
[root@stagedb3 ~]# vi /etc/sudoers
scorfield ALL=(oracle) NOPASSWD: /usr/local/bin/kill_listener.sh
Now Test it:
[scorfield@stagedb3 ~]$ sudo -i -u oracle /usr/local/bin/kill_listener.sh
Tried to kill Oracle listener(s), check with ps -ef if the process(es) died
[scorfield@stagedb3 ~]$ ps -ef | grep LISTENER|grep oracle
There should not be any process running.