change the shutdown sequence in red hat linux

Hi,
I use red hat linux kernel 2.6
I want to add the application shutdown in shutdown sequence .
I add the K script in /etc/rc.d/ all sub directory for all
running level .
But the auto shutdown application is not appear when
I type "shutdown -r now" ..
There is no indication the application shutdown in the
display ...
The shutdown seq is hang/stop and I need to shutdown the application
by command manually .Then the shutdown process can be continue ....
Why ??/
how can I change the shutdown seq ???
Any advice ...

Use chkconfig. The following article should help you: Managing Initscripts with Red Hat's chkconfig

HTH,
Lo�c.

Hi,
No, It is only work in starupt seq .
For shutdown seq , it is still hang and I need to manual to
shutdown the application and continue the shutdown process.....

Any advice ??????

---------- Post updated at 02:59 PM ---------- Previous update was at 02:30 PM ----------

I use chkconfig but I cannot create the K script , only S script present ....
Why ???gcota is my application name
there is no K script for gcota ....

[root@TSTgcota init.d]# chkconfig gcota reset
[root@TSTgcota init.d]# find /etc/rc.d -name "*gcota*" -print
/etc/rc.d/rc2.d/S96gcota
/etc/rc.d/rc3.d/S96gcota
/etc/rc.d/init.d/gcota
/etc/rc.d/rc1.d/S96gcota
/etc/rc.d/rc5.d/S96gcota
/etc/rc.d/rc6.d/S96gcota
/etc/rc.d/rc0.d/S96gcota
/etc/rc.d/rc4.d/S96gcota

[root@TSTgcota init.d]# ls -lt gcota
-rwxrwxrwx  1 root root 1269 Jan 29 14:58 gcota
[root@TSTgcota init.d]#

[root@TSTgcota init.d]# cat gcota
#! /bin/bash
#  chkconfig: 0123456 96 16
# description: start up GCOTA application
# processname: gcota

First check that K16* is not already is use. If it is , use another number. Then change

#  chkconfig: 0123456 96 16

to

#chkconfig: 2345 96 16

and try again.

Why the init level 3 ,4 ,5 not present a S script for gcota and
a K script for gcota ???
Only init level 0 ,1,2,6 present K script
init level 3 ,4, 5 present S script ??
Why do it not present both script in the same level ????

[root@TSTgcota init.d]# find /etc/rc.d -name "*gcota*" -print
/etc/rc.d/rc2.d/K04gcota
/etc/rc.d/rc3.d/S96gcota
/etc/rc.d/init.d/gcota
/etc/rc.d/rc1.d/K04gcota
/etc/rc.d/rc5.d/S96gcota
/etc/rc.d/rc6.d/K04gcota
/etc/rc.d/rc0.d/K04gcota
/etc/rc.d/rc4.d/S96gcota
[root@TSTgcota init.d]# head -20 /etc/initd./gcota
head: cannot open `/etc/initd./gcota' for reading: No such file or directory
[root@TSTgcota init.d]# head -20 /etc/init.d/gcota
#! /bin/bash
#  chkconfig: 345 96 4

This is absolutely coherent with your chkconfig definition:

chkconfig: 345 96 4

You just told: activate my service at runlevel 3,4,5 (hence a S script at those levels), and shutdown service at the other level (hence a K scripts at levels 0,1,2,6).
When you reboot or halt, the runlevel 6 (or 0) shall be invoked, hence calling the K script.

HTH,
Lo�c.