nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

UNIX shell script

This is a discussion on UNIX shell script within the Shell scripting forums, part of the Development/Scripting category; Hi, Through my Shell script i want to check whether Database is UP or not before executing the SQL commands. ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2008, 06:04 PM
Junior Member
User
 
Join Date: Sep 2008
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
AAgarwal8 is on a distinguished road
Smile UNIX shell script

Hi,

Through my Shell script i want to check whether Database is UP or not
before executing the SQL commands.
if not then It should throw message of NO Success.
currently if database is down still shows the process as success.
I am working on UNIX korn shell
as I am new to UNIX if any one can help me out

Thanks....
Reply With Quote
  #2 (permalink)  
Old 09-05-2008, 08:54 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,697
Thanks: 11
Thanked 243 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Can you share your database and os name?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 01:40 AM
capibolso's Avatar
Junior Member
User
 
Join Date: Jan 2008
Location: Montevideo, Uruguay
OS: SUSE, Ubuntu
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
capibolso will become famous soon enough
Default

If your database is mysql
Code:
#!/bin/sh
SERV=mysqld
if pidof $SERV > /dev/null; 
then echo "$SERV running"; 
else echo "$SERV down"; 
fi
Otherwise change SERV to your service (database) launcher.
Good luck!
:wq

Last edited by capibolso; 09-07-2008 at 01:44 AM.
Reply With Quote
  #4 (permalink)  
Old 09-08-2008, 01:29 PM
Junior Member
User
 
Join Date: Sep 2008
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
AAgarwal8 is on a distinguished road
Default

Hi,

We are working on Oracle database and we run the shell script on UNIX.
Reply With Quote
  #5 (permalink)  
Old 09-08-2008, 07:36 PM
capibolso's Avatar
Junior Member
User
 
Join Date: Jan 2008
Location: Montevideo, Uruguay
OS: SUSE, Ubuntu
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
capibolso will become famous soon enough
Default

Try this
Code:
#!/bin/sh
DBSTAT=`ps -ef | grep pmon | grep ${ORACLE_SID} | grep -v grep | wc -l`
if [ "$DBSTAT"="0" ]
then 
echo "Database down"
else
echo "Database up"
fi
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Access UNIX Shell via PHP Based Frontend eawedat Shell scripting 4 08-29-2008 02:16 AM
Execute UNIX Command / Shell Script Once In The Future permalac Shell scripting 2 08-27-2008 08:13 PM
Binary Conversion Of Shell Script (shell script compiler) chandanperl Shell scripting 3 07-29-2008 10:22 AM
unix shell on windows xp chiku Solaris/OpenSolaris 4 03-07-2008 03:17 PM
Linux UNIX SFTP in a Shell Script Nishanthhampali Shell scripting 1 01-30-2008 01:16 PM


All times are GMT +5.5. The time now is 12:06 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38