-   Linux - Newbie (
-   -   Scripts under rc0.d and rc6.d do not seem to run during shutdown.reboot (

oferu 04-27-2006 03:02 AM

Scripts under rc0.d and rc6.d do not seem to run during shutdown.reboot

I am using RedHat 9 and have problems running scripts that should run during shutdown/reboot.

I placed a script under /etc/init.d/ ('my_script') and made a symbolic link (K40my_script)to it in /etc/rc0.d/ (for shutdown) and /etc/rc6.d/ (for rebooting).

However, when I shutdown/reboot I do not see (during shutdown/reboot on the screen within the list of scripts being run) that my scripts run.

During startup (boot), I do see (on the screen within the list of scripts running) that the script (symbolic link, 'S99my_script' under /etc/rc5.d/) runs.

Does anyone have an idea why my script does not run during shutdown/reboot although it exists as a symbolic link under rc0.d and rc6.d?


pixellany 04-27-2006 09:43 AM

When you put a link in rcX.d, the first letter tells the system to either start (S) or kill (K) the process. If you have K for kill, then I'm not sure you would see anything happening.
Did you want your script to start or kill when re-booting or shutting-down?

oferu 04-27-2006 11:27 AM

Shutting down/re-boot and rc0.d / rc6.d
Thank You for your reply.

The scripts aim to stop processes that are running. As such I think they should be 'K'. I also thought that all scripts in rc0.d and rc6.d which are shutdown and re-boot levels should be 'K'. Do you think they may need to be 'S'? What is the meaning of an 'S' script during shutdown (isn't shutdown when you want to kill (and not start) all processes?)

I thought that maybe the scripts do actually run (and I just do not 'see' them run on the console). But then:
a. I get a 'FAIL' on the screen when the system tries to shut down PPP0 (during shutdown) and that proves to me that my script is not running (it is a script that stops my internet cable connection). Had my script run, I expect PPP0 to be shut without failing.

b. If K20mysql exists under rc6.d and during re-boot I see on the screen that the mysql is running (stopping), why would I not see K40my_script run during re-boot (it is also under rc6.d)?


rogbazan 04-13-2007 07:09 PM

the same problem!!!
I have de same problem....and it is growing 'cause any scripts i add to the rc's does not oracle, tuxedo, mqseries, etc.

If you know any solution...please let me know.
i'm running red hat enterprise linux and fedora..... 03-26-2008 11:34 AM

The reason RedHat does not kick off your K* rc shutdown scripts is because RedHat checks for a lock file for your script in /var/lock/subsys/<scriptname>

To fix this, simply add a line to your 'start' section, something like this:

touch /var/lock/subsys/<scriptname>
This will create that 0 byte file that rc is looking for when it executes shutdown.

Here is the actual snippet of the code from /etc/rc.d/rc that does this:

# 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.
        [ -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
                action $"Stopping $subsys: " $i stop

good luck,

All times are GMT -5. The time now is 03:13 AM.