jacob Site Admin


Joined: 16 Mar 2006 Posts: 73 Location: USA
|
Posted: Wed Mar 26, 2008 3:52 pm Post subject: Why RedHat does not stop in rc0.d and rc6.d ... |
|
|
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
|
|