Re: (AIX 5L) (NOT A) MYTH: Shutdown scripts can be placed in /etc/rc.d/rcX.d



Thanks to Casey and J.J. for their excellent replies. I had a
feeling I was going to get educated, and I was right! Here is a bit
more for anyone following along, some additional information that they
might find useful.


Of course, casey was right about shutdown being a shell script, and
calling only the kill scripts. Duh!!! -- just goes to show what being
a newb is all about!

In looking at the shutdown script, it appears as I read it that the
KillScripts in every rc.d/rcX.d will get run, since they all get
collated together. Again, nothing to get to excited about, but not
very obvious or intuitive. I would have expected that it would have
checked the current run level and would have run only those K's. But
what the hey. (For entertainment, I've cut out the script segment
and again pasted at the bottom of this post.)

Re JJs post --- as he notes, he hasn't worked with AIX, and in fact
the run levels are in fact different. (In fact they are pretty much
undefined except that 0 and 1 are "reserved" and 2 is offically
defined as Multiuser mode with NFS resources shared. There's also a
special a,b and c "psuedo" level.) I can see where his suggestion on
utililing "K" scripts would be useful if AIX used them in a more
standard method. (Although I'd still posit that it would just be
cleaner/ more intuitive if at startup only the S scipts were run. If
a run level change was made, firstrun the kill kill scripts in your
current runlevel, then the startup in the level you are moving to.
But since that is a wish and not how AIX behaves, his point is well
taken.)


Again, thanks to both gents, and hope posterity finds this post useful
somehow! ;-0

















============ SHUTDOWN scrpt excerpt =============
# Let system know that we are starting our shutdown sequence.
reboot -p

if [ $nohalt = off ]
then
# /etc/rc.shutdown is for adminstrators to create for
their
# own local needs. If it is not successful, shutdown
will
# abort.
if [ -x /etc/rc.shutdown ]
then
sh /etc/rc.shutdown
if [ $? -ne 0 ] ; then
dspmsg -s 1 shutdown.cat 60 \
"/etc/rc.shutdown failed. Shutdown aborting.
\n"
exit 1
fi
fi

# Added to run stop scripts for all runlevels

rcdirs=`ls /etc/rc.d | grep "rc[0-9].d"`
echo "${rcdirs}" | while read dir
do

#get a list of the "kill" scripts in this directory
k_list=$(ls /etc/rc.d/${dir} | grep "^K" | sort -)

#execute "kill" scripts
if [[ -n ${k_list} ]] then
echo "${k_list}" | while read item
do
/etc/rc.d/${dir}/${item} stop
done
fi

done

# End of stop scripts

============ SHUTDOWN scrpt excerpt end =========












.



Relevant Pages

  • Root: Cannot kill own process...
    ... Now the thing is, that kill doesn't kill. ... could "destroy" root processes, but still, "ip-down" ... was not able to stop the ping. ... but from the scripts, I can't. ...
    (comp.os.linux.security)
  • Re: All New rc2.d Scripts get Ignored. Debian from KNOPPIX Solved!
    ... kill or start scripts in each rc directory. ... came up on boot for the first time on the next boot. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Random pids being "16113 Killed "
    ... a script or some other process that is looking for a pattern and ... any "kill" logic involved. ... Having written similar scripts in the past, ... None of the processes run as root. ...
    (comp.unix.solaris)
  • Re: Why does /etc/rc.d/rc work the way it does?
    ... ]>> from the current level and then start scripts from the new level. ... it runs both the kill scripts and start scripts from the new level. ... For example level 3 has networking and level 2 does not. ... in all runlevels. ...
    (comp.os.linux.setup)
  • Re: Most Kill scripts not executed at shutdown ?
    ... The only kill scripts run on shutdown are those starting with K in ... and then does a general kill once it has done a controlled kill by the ... It is certainly not necessary for a lock file to be there. ...
    (comp.os.linux.misc)