Kill Duplicated Process by shell in crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Kill Duplicated Process by shell in crontab
# 1  
Old 12-14-2011
Kill Duplicated Process by shell in crontab

Hi!

I need your help, please.

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.

Anyone can help me?

PS: Sorry about english, i'm from south america Smilie
# 2  
Old 12-14-2011
What version of Oracle. What Operating System and version? Which Shell?

Don't issue unix "kill" to Oracle processes.

Check whether the listener shows up in a "lstnrctl" command.
Lsnrctl - Oracle FAQ
# 3  
Old 12-14-2011
Hi, thx for asking.

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!
# 4  
Old 12-14-2011
There is an Oracle temporary fix mentioned in this blog (and many other blogs).
Solaris Mike R's Blog


Please mention what Shell you use for administrative scripts (ksh?) and post the output from :
Code:
ps -fea|grep tns

ps -ef|grep "tnslsnr"

ps -fu oracle | grep "tnslsnr"

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).
# 5  
Old 12-14-2011
Thanks por replying.

We used sh for administrative scripts

Code:
$ ps -fea|grep tns
oracle10 1175748       1   7   Dec 09      - 123:33 /oracle10g/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle10 1339466 1605770   0 12:07:31  pts/0  0:00 grep tns
$ ps -ef|grep "tnslsnr"
oracle10 1175748       1   5   Dec 09      - 123:33 /oracle10g/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle10 1679534 1605770   0 12:07:42  pts/0  0:00 grep tnslsnr
$ ps -fu oracle | grep "tnslsnr"
$

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.

Thanks again!! Smilie
# 6  
Old 12-14-2011
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.
Code:
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

This User Gave Thanks to methyl For This Post:
# 7  
Old 12-14-2011
Thanks! Smilie I will test it tomorrow. I let you know how it goes.

Thanks Again! Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to report file size, pid and also kill the process

Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
Discussion started by: vasavimacherla
4 Replies

2. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

3. Shell Programming and Scripting

shell script to find a process by name and kill it

hi, Am a newbie to unix and wasnt able to write script to my requirement. I need a shell script, which should find a process by name and kill it. For eg: let the process name be "abc". I have different processes running by this name(abc), so should kill them all. Condition would be: if... (7 Replies)
Discussion started by: fop4658
7 Replies

4. Shell Programming and Scripting

Cron job and shell script to kill a process if memory gets to high

Hello, I'd like to set a cron job that runs a shell script every 30 minutes or so to restart a java based service if the memory gets above 80%. Any advice on how to do this? Thanks in advance! - Ryan (19 Replies)
Discussion started by: prometheon123
19 Replies

5. Shell Programming and Scripting

shell script to kill process with respect to terminal

Hi, I've a script which kills all process, but i need a script shell script(sh), where it'll kill process on that particular terminal. below is example TY=`tty` for P in $TY do `kill -9 $P 2>/dev/null`; done echo "test process killed" break ... (3 Replies)
Discussion started by: asak
3 Replies

6. Shell Programming and Scripting

Kill a process from parent shell within a shell script

Hi, I am looking for a solution for the following problem: Im Using tcpdump within a shellskript started in a subshell by using brackets: ( /usr/sbin/tcpdump -i ... -c 1 ) - I want the outout of tcpdump saved in a variable - Than tcpdump-Process in the Subshell should be killed - and I... (6 Replies)
Discussion started by: 2retti
6 Replies

7. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

8. UNIX for Dummies Questions & Answers

crontab or looping script to Kill process from user

I am looking for a way to kill 2 processes from a user through some kind of script. Using an oracle script, I get two process ids that need to be killed. SQL> select ssn.process as client_process_id, pcs.spid as oracle_process_id, ssn.sid, ssn.serial# 2 from v$session ssn inner join... (5 Replies)
Discussion started by: Meert
5 Replies

9. Shell Programming and Scripting

kill a process initiated by crontab

Hi, I scheduled one script through crontab command and seems like it is hanging. I come to know this through the command 'ps -ef' whcih is showing me the program running, but no chances of it to take more than 2hrs to comlpete. I want to kill that process. I tried to kill it using the... (6 Replies)
Discussion started by: DILEEP410
6 Replies

10. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies
Login or Register to Ask a Question