LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-15-2010, 11:20 AM   #1
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 504

Rep: Reputation: 34
init script does not run at the shutdown time


Hi I’m having a bit of a problem with a init script which I wrote to start and stop oracle listener and database. My system is Redhat 5.4 64bit and oracle 10g2 standard database (64).
I have created the script and added the script using

chkconfig –add orashut, and on the script by

chkconfig –level 345 orashut on

Now I can use service orashut start, stop, restart, and works fine and when the system comes up the database and the listener would come up as planed. But the problem is when I do a reboot or shut down the db or the listener would not shutdown as expected, I placed at K00 values as well in rc0.d and rc6.d to give the priority at the shutdown. Even though all the configurations say this script should run before everything else at the shutdown time this is not working.

Can some one tell me what I am doing wrong

Thanks
Best regards
 
Old 02-15-2010, 01:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
You forgot to add the relevant runlevels in chkconfig.
0 and 6

Why it's not running when you manually added them ...
did you make it executable? Are the manually created
links pointing at the right file?

Cheers,
Tink

Last edited by Tinkster; 02-15-2010 at 01:07 PM.
 
Old 02-15-2010, 03:09 PM   #3
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 504

Original Poster
Rep: Reputation: 34
Talking

Hi Thakns for the reply, but I am bit confused

when I do chkconfig --list | grep orashut it gives me this out put
orashut 0 : off 1 : off 2 : off 3 : on 4 : on 5 : on 6 : off

This mean all runlevels are oka and it I go the /etc/rc.d/rc0.d and rc6.d I can find K00orashut -> ../init.d/orashut in both places so acording to this things should be okay (at least I hope )

Please let me know what I a am doing wrong, when he shutdowns I dont even see a error message.

Only good thing is the startup script works oks and I can do service orasut start|stop|restart at the command prompt with out any issue.

Thanks and regards
 
Old 02-15-2010, 03:41 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
In that case you may wish to post the script - chances are your
code is faulty :}
 
Old 02-16-2010, 03:00 AM   #5
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 504

Original Poster
Rep: Reputation: 34
Hi Tinkster, below is my start and stop script, thanks bser regards



#!/bin/bash
#
# Oracle 10g2 This shell script takes care of starting and stopping
# Oracle 10g2.
#
# chkconfig: 345 95 00
# description: Oracle 10g2 service listner and database
#
# processnameracledb
# config: /etc/oratab

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

export ORACLE_BASE="/home/app/oracle"
export ORACLE_HOME="/home/app/oracle/product/10.2.0"
export ORACLE_HOME_LISTNER=${ORACLE_HOME}
export ORA_OWNR="oracle10g2"

RETVAL=0
prog="Oracle10g2"

start() {
# Start Oracle process.

[ -f $ORACLE_HOME/bin/lsnrctl ] || exit 4
[ -f $ORACLE_HOME/bin/dbstart ] || exit 4

site="Listner"
echo -n $"Starting $site for $prog: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
site="db"
echo -n $"Starting $prog "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
echo
return $RETVAL
}

stop() {
# Stoping Oracle process.

[ -f $ORACLE_HOME/bin/lsnrctl ] || exit 4
[ -f $ORACLE_HOME/bin/dbshut ] || exit 4

site="Listner"
echo -n $"Stoping $site for $prog: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
site="db"
echo -n $"Stoping $prog "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
echo
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
asarestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|asarestart|status}"
exit 2
esac

exit $RETVAL
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 09:15 PM
Run init script as daemon isuck@linux Linux - Software 5 02-12-2007 02:29 AM
Can't get script to run from symlink in etc/init.d goggyturk Debian 5 12-05-2006 01:34 PM
How to run a script at startup after a shutdown? kklein9 Linux - Software 3 01-27-2006 04:32 PM
init script won't run at log-off dimangi Linux - Newbie 1 10-29-2003 03:19 AM


All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration