The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Tech Article: Guide to Oracle Data Guard Fast-Start Failover iBot Oracle Updates (RSS) 0 05-27-2009 05:00 PM
Oracle Cluster Ready Services waiting for SunCluster on x86 to start amitranjansahu UNIX and Linux Applications 0 05-19-2009 01:49 AM
Tech Article: Guide to Oracle Data Guard Fast-Start Failover iBot Oracle Updates (RSS) 0 03-23-2009 03:45 PM
How to start Oracle database automatically greg0320 SUN Solaris 3 03-30-2005 05:46 PM
Start application after Oracle has started Piet UNIX for Advanced & Expert Users 3 08-13-2003 12:31 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2009
prakash.gr prakash.gr is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 32
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 10:17 AM.. Reason: Fix spelling in title
  #2 (permalink)  
Old 06-13-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
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 (permalink)  
Old 06-13-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
You can simplify it a bit:

Code:
exec >/dev/null 2>&1
lsnrctl status || lsnrctl start
  #4 (permalink)  
Old 06-14-2009
prakash.gr prakash.gr is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 32
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 (permalink)  
Old 06-14-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
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 06:03 AM..
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0