HowToForums.net Forum Index HowToForums.net
An Open Source of Knowledge
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why RedHat does not stop in rc0.d and rc6.d ...

 
Post new topic   Reply to topic    HowToForums.net Forum Index -> Linux Tips & Tricks
View previous topic :: View next topic  
Author Message
jacob
Site Admin
Site Admin


Joined: 16 Mar 2006
Posts: 73
Location: USA

PostPosted: Wed Mar 26, 2008 3:52 pm    Post subject: Why RedHat does not stop in rc0.d and rc6.d ... Reply with quote

The reason is ...
RedHat checks for a lock file for your script in /var/lock/subsys/<scriptname>

For example, lets say you created a script to shutdown your application in: /etc/init.d/SomeApp
And you created symbolic links to this script in /etc/rc.d/rc0.d/ and /etc/rc.d/rc6.d/ such as:
Code:

/etc/rc.d/rc0.d/K04SomeApp -> ../init.d/SomeApp


In order for your script to work, it must create the lock file in the start section.
For example:
Code:

#!/bin/bash

if test "$1" = "start"
then
        /etc/init.d/SomeApp start
        touch /var/lock/subsys/SomeApp
elif test "$1" = "stop"
then
        /etc/init.d/SomeApp stop
fi


The 'touch' command is the critical line in the code above.
It is the one that /etc/rc.d/rc is looking for here:
snippet from RedHat rc system script:
Code:

# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
        check_runlevel "$i" || continue

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

        # Bring the subsystem down.
        if egrep -q "(killproc |action )" $i ; then
                $i stop
        else
                action $"Stopping $subsys: " $i stop
        fi
done


good luck,
Jacob
http://howtoforums.net



<keywords>
rc scripts not shutting down
rc.0 rc.6 K* not working
understanding runlevels
inittab
stop start with runlevels redhat
Back to top
Display posts from previous:   
Post new topic   Reply to topic    HowToForums.net Forum Index -> Linux Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group