Thursday, January 27, 2011

My init.d script is never called with the stop parameter?

I created a script called blueBoxT for starting and stopping Oracle and placed it in the /etc/init.d directory.

#!/bin/bash
echo "blueBoxT $1 - `date '+%Y%m%d%H%M'`" >> /root/blueBoxT.log
case "$1" in
  'start')
    echo "Starting Oracle"
    su - oracle -c "/home/oracle/startDBT"
    ;;
  'stop')
    echo "Stopping Oracle"
    su - oracle -c "/home/oracle/stopDBT"
    ;;
  *)
    echo "`basename $0`: usage: `basename $0` { stop | start }"
    ;;
esac
exit 0

I made the symbolic links as so...

root@dev /etc/rc.d
# find . -name *blueBox*
./rc2.d/K11blueBox
./rc6.d/K11blueBox
./init.d/blueBoxT
./rc1.d/K11blueBox
./rc3.d/S97blueBox
./rc0.d/K11blueBox
./rc5.d/S97blueBox
./rc4.d/S97blueBox

The log at /root/blueBoxT.log shows the start command and the Oracle instance is up.

The stop command never appears to get called. It is not in my log.

root@dev /root
# cat blueBoxT.log
blueBoxT start - 201008051323
blueBoxT start - 201008051327
blueBoxT start - 201008051346
blueBoxT start - 201008051356

I shutdown my Fedora 10 using the command...

shutdown -h now

What have I misconfigured to not be receiving the stop so that I can do an orderly shutdown of Oracle?

  • I don't have that version of Fedora but for RHEL5 the important part of /etc/rc.d/rc is:

    subsys=${i#/etc/rc$runlevel.d/K??}
    [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
            || continue
    

    Your problem may be that you don't touch a /var/lock/subsys/blueBox when starting.

    Also the file in init.d is called blueBoxT whereas your rc?.d scripts are called K??blueBox (no trailing T) which is confusing.

    Zypher : K?? and S?? files in `/rc?.d` scripts are just symlinks back to the `/etc/init.d` script. They don't have to be named the same in fact due to the K??|S?? part they can't be named the same.
    James : +1, make sure to touch the lock files
    dacracot : I corrected the "missing T", but I don't think that was the problem. The lock seems to have done the trick!
    From embobo

0 comments:

Post a Comment