lsnrctl start script for Oracle on Solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting lsnrctl start script for Oracle on Solaris
# 1  
Old 06-13-2009
lsnrctl start script for Oracle on Solaris

Hi,

os version :sun solaris 5.9

I have a problem with one of production server where listener will die frequently,

I have raised SR with oracle for the same, but mean time i need simple script and i need schedule in cron for every 5 min if listner will down it will start automatically.

this is the script but i am getting error appreciated for inputs.


Code:
lsnrctl status > /oracle/test.txt
aaa=`grep "The command completed successfully" /oracle/test.txt`
bbb="The command completed successfully"
ccc="TNS:no listener"
if ["$aaa" = "$bbb"]; then
exit
else
if ["$aaa" = "$ccc"]; then
lsnrctl start
fi
fi
exit

bash-2.05$ sh listener.sh
listener.sh: test: ] missing


Thanks

Prakash

Last edited by fpmurphy; 06-13-2009 at 11:17 AM.. Reason: Fix spelling in title
# 2  
Old 06-13-2009
Your problem is lack of white space. You need a space after [ and before ] otherwise the shell cannot parse your script. See man [.
Code:
.....
if [ "$aaa" = "$bbb" ]; then
......
if [ "$aaa" = "$ccc" ]; then
......

# 3  
Old 06-13-2009
You can simplify it a bit:

Code:
exec >/dev/null 2>&1
lsnrctl status || lsnrctl start

# 4  
Old 06-14-2009
Hi,

Code:
bash-2.05$ cat listener.sh
lsnrctl status > /oracle/test.txt
aaa=`grep "The command completed successfully" /oracle/test.txt`
bbb="The command completed successfully"
ccc="TNS:no listener"
if [ "$aaa" = "$bbb" ]; then
exit
else
if [ "$aaa" = "$ccc" ]; then
exec >/dev/null 2>&1
lsnrctl status || lsnrctl start
fi
fi
exit

script is executed but it is not starting listener.

Thanks

Prakash
# 5  
Old 06-14-2009
Sorry for not being clear, listener.sh should contain only the code below:

Code:
exec >/dev/null 2>&1
lsnrctl status || lsnrctl start

It will produce no output.

P.S. It should be definitely better to leave STDOUT/ERR.
So your script should contain only the line below
and you should redirect its STDOUT/ERR to a logfile:

Code:
lsnrctl status || lsnrctl start


Last edited by radoulov; 06-14-2009 at 07:03 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Stop/start script problem on Solaris-10

I have Big brother script, which start/stop Big Brother processes. Something got change on server and now I am not able to start/stop it. There is no change in script, as I compared it from other server. This service is being managed by bb user (group is also bb). root@tsazdq04:/#... (6 Replies)
Discussion started by: solaris_1977
6 Replies

2. Shell Programming and Scripting

Oracle DB Start shutdown scripts

Hi, We have a requirement wherein we do not want to share the Oracle DB sys and system passwords to be shared with the support desk. But they will be responsible for starting/shuting down the Database. Is it possible to write a shell script which will read the sys and system passwords from a... (0 Replies)
Discussion started by: narayanv
0 Replies

3. Shell Programming and Scripting

Solaris+Perl script to get process start date

Hi all, after reading the post: * https://www.unix.com/solaris/101653-how-get-process-start-date-time-solaris.html I wrote my perl script and it worked like a charm. This script is called every 5 minutes by the monitoring server crontab and is executed on the remote network elements via ssh (the... (6 Replies)
Discussion started by: Evan
6 Replies

4. Shell Programming and Scripting

Script to drop oracle DB users on HP, LINUX, SOLARIS

Hi everybody, i need help from all of you. I have many users who are no more work in our Company. Some who get objects are Locked. There Many users and many Database Servers. And it'll take long for me to finished this job. That's why i need your help to provide me anyone Scripts... (2 Replies)
Discussion started by: Sonson
2 Replies

5. Solaris

how do I start a script in run level 3 in solaris?

Hi, how do I start a script in run level 3 in solaris? (4 Replies)
Discussion started by: mokkan
4 Replies

6. Solaris

How to start Oracle database automatically

How to start Oracle database automatically when after SunSolaris is being re-booted? TIA, Greg (3 Replies)
Discussion started by: greg0320
3 Replies

7. UNIX for Advanced & Expert Users

Start application after Oracle has started

Who can tell me how I can see to it that a application doesn't try to start it's processes untill Oracle has completely started. Thanx. (3 Replies)
Discussion started by: Piet
3 Replies
Login or Register to Ask a Question