Check for DB status and startup DB


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check for DB status and startup DB
# 8  
Old 05-14-2013
What method do you use to startup the DB? do you use any scripts (in case of dataguard installed) or you log on to SQL as sysdba and run startup?

---------- Post updated at 02:21 PM ---------- Previous update was at 02:13 PM ----------

You can use this..

Code:
 
for line in `awk -F"[#:*]" 'NF==3&&$1~/./{print $1}' /wload/clht/app/etc/oratab` ; do
ps -ef|grep $line|grep pmon  > /dev/null
if [ $? -eq 0 ] ; then
echo "DB $line is up and running"
else
echo "DB $line is not running"
#Your DB startup script goes in here I would say set ORACLE_SID to $line before you startup
fi
done

# 9  
Old 05-14-2013
thanks for the script
when i execute this i am getting nothing,
can u please explain the awk part?
Code:
for line in `awk -F"[#:*]" 'NF==3&&$1~/./{print $1}' /var/opt/oracle/oratab` ; do
ps -ef|grep $line|grep pmon > /dev/null
if [ $? -eq 0 ] ; then
echo "DB $line is up and running"
else
echo "DB $line is not running"
fi
done

FYI,i ll connect as sysdba then i ll start the DB
# 10  
Old 05-14-2013
Can you run the script as
Code:
 sh -x script_name

and post the o/p?
# 11  
Old 05-14-2013
Code:
awk -F[#:*] NF==3&&$1~/./{print $1} /var/opt/oracle/oratab

# 12  
Old 05-14-2013
Quote:
Originally Posted by navsan420
Code:
awk -F[#:*] NF==3&&$1~/./{print $1} /var/opt/oracle/oratab

This doesnt look like what i asked for Smilie
# 13  
Old 05-14-2013
what u want to know
Code:
host $ sh -x test.ksh
+ awk -F[#:*] NF==3&&$1~/./{print $1} /var/opt/oracle/oratab

# 14  
Old 05-14-2013
I am puzzled as per your entries in oratab file it should work Smilie
If you run that awk on command prompt is it returning any result or just blank?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check status of process

Hi All, Have a query How to check for a process and if down start it , try if for 2 times and its not starting don't do it My code is working to some extent but while starting try starting both times. Please advise , whats wrong here ? if you have any other approach please do share. My... (1 Reply)
Discussion started by: abhaydas
1 Replies

2. UNIX for Advanced & Expert Users

Check for DB status and startup DB

EXPERTS, I need a shell script to check the DBs status (Running/Shutdown) in the server.If its Running then no issue but if it is in shutdown state ,it should prompt like " DB is shut down you want to startup??" if i enter YES it should startup. ORACLE_SID are present in /var/opt/oracle/oratab ... (0 Replies)
Discussion started by: navsan420
0 Replies

3. Shell Programming and Scripting

Check HD status

I have some server ( IBM , Dell ) , our data center is not in the same location with office , therefore , I do not know if the HD lamp is flash when the HD is fault , can advise if I can write a script to check if the HD is normal running or not ? thanks (1 Reply)
Discussion started by: ust
1 Replies

4. UNIX for Advanced & Expert Users

Check the status of job

Hi, I have master job which will run based on the sub jobs status. In the master job I am giving the condition like, condition: s(sub_job) f(sub_job) This scenario will work if the sub job status is success or failed. but I want to run my master job even if the sub_job was... (1 Reply)
Discussion started by: Kattoor
1 Replies

5. Shell Programming and Scripting

Need help to check the jobs status

Hello All, I'm new in shell scripting and would like to write an automated script that will check few jobs for the completion, and restart the process based on the jobs status. I am not quite sure how do I check the job status... Can someone please help? Any help will be appreciated. Thanks in... (1 Reply)
Discussion started by: mohullah
1 Replies

6. AIX

check the status of ypbind

hello , How do i to check the status of ypbind on AIX(5.3) platform ? Thanks AVK Linux (1 Reply)
Discussion started by: avklinux
1 Replies

7. Shell Programming and Scripting

Check FTP Status

To all, I need to run a ftp command in one of my scripts and I need to evaluate what happens after it's done. The problem is the script would not capture the ftp responses. If I type the same thing on the command line, I get all kinds of responses. I would like to capture the same responses in... (2 Replies)
Discussion started by: april
2 Replies

8. Shell Programming and Scripting

How to check the FTP Status?

Hi, I wrote a script that is generating a file and then i have to ftp this file on another server. For this i am using mput to put the file. How can i make sure that the file was ftp'd correctly to the another server, is there any status check ? Thanks. (1 Reply)
Discussion started by: smc3
1 Replies

9. HP-UX

sftp status check

Hi All, I am having shell scripts that make use of ftp to fetch data from one hp-ux box to another. Currently we are migrating these scripts to sftp. Is it a straight forward one? Also, please clarify my following doubts: 1) In ftp we check the success of ftp by verifying the status codes... (4 Replies)
Discussion started by: fisa
4 Replies

10. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies
Login or Register to Ask a Question