LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Why won't my FC3 rc0 and rc6 levels not call kill script when entering those levels? (http://www.linuxquestions.org/questions/linux-general-1/why-wont-my-fc3-rc0-and-rc6-levels-not-call-kill-script-when-entering-those-levels-327101/)

dvkwiatk 05-25-2005 05:12 PM

Why won't my FC3 rc0 and rc6 levels not call kill script when entering those levels?
 
I have a script, that will eventually start/stop my oracle services. However, when the machine shuts down/reboots, the command to kill the processes is never invoked. I've removed the actual calls to start and stop the processes to help troubleshoot.

Linux: Fedora Core 3 - latest kernel build

The following script, resides in /etc/init.d with permissions 755 root.root.
I can run this manually and the script executes as expected.
#!/bin/sh
#
# chkconfig: 35 91 35
# description: Startup/Shutdown Oracle Services.
#

logfile=/var/log/oracle.log

case "$1" in
start)
echo "Start" >> $logfile
;;
stop)
echo "Stop" >> $logfile
;;
restart)
echo "Restart" >> $logfile
;;
reload)
echo "Reload" >> $logfile
;;
status)
echo "Status" >> $logfile
;;
condrestart)
echo "Condrestart" >> $logfile
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
exit 1
esac

exit 0

So far, I've have used the chkconfig utility and it properly creates the K35oracle and S91oracle in the appropriate run levels. However, when the machine is either rebooted or shutdown the Kill is never invoked.

I have also tried to just create the links myself using ln -s ../init.d/oracle K35oracle in run levels 0 & 6 along with the S in level 5. On startup, the script is always executed and an entry shows in the logfile as expected. I'm probably missing the obvious but if anyone has any ideas I would greatly appreciate your thoughts...

Thanks,
Ed

shrewmouse 10-30-2006 01:53 PM

The fact that this isn't documented in chkconfig is a real pain in the rear but here's the answer.

/etc/rc is the script responsible for running each script in /etc/rc*.d. Before running each K* script, rc performs the following check.

Code:

        # Check if the subsystem is already up.
        subsys=${i#/etc/rc$runlevel.d/S??}
        [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
                && continue

If your script is called K01snowdog, then rc looks for /var/lock/subsys/snowdog or /var/lock/subsys/snowdog.init. If either of these files exist then "K01snowdog stop" is executed. If neither snowdog nor snowdog.init exist "K01snowdog stop" will not be called.

You need to change your script to create and destroy the correct file in /var/lock/subsys:

Code:

start)
touch /var/lock/subsys/snowdog
echo "Start" >> $logfile
;;
stop)
echo "Stop" >> $logfile
rm -f /var/lock/subsys/snowdog
;;


dvkwiatk 11-11-2006 08:09 AM

Thanks, Shortly after posting I reviewed some of the built-in scripts and discovered the /var/lock/subsys lines and added them to my scripts. Everything is working great.

Thanks,
Ed


All times are GMT -5. The time now is 08:33 PM.