Hi,
I have a script which start at system starts and it suppose to stop itself and send a message to me. It works only for start up, for shutdown it's killed before the stop command is executed by this script. here is what I do.
I have two scripts, one is for start up. for example start.sh
another is for stop, for example stop.sh
My OS is :
[HTML][root@centos5 ~]# uname -a
Linux centos5 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:34:18 EDT 2008 i686 i686 i386 GNU/Linux[/HTML]
I create a script in /etc/init.d called robinsrv. and run the chkconfig --add robinsrv and added it as a service.
I have tested it by using
[HTML]service robinsrv start
service robinsrv stop
service robinsrv status[/HTML]
everything works fine. when I execute service robinsrv stop I'll receive email.
I let it run on runlevel 345.
[HTML][root@centos5 ~]# chkconfig --list robinsrv
robinsrv 0
ff 1
ff 2
ff 3
n 4
n 5
n 6
ff[/HTML]
Now the problem is when the system is down, no email is received from the stop script, it hasn't been executed or it the main process has been killed before stop script get executed. My service doens't rely on any other service(I mean non-system basic service.)
Here is the defalt kill sequece:
[HTML][root@centos5 ~]# find /etc/rc.d -name K??robinsrv
/etc/rc.d/rc6.d/K10robinsrv
/etc/rc.d/rc2.d/K10robinsrv
/etc/rc.d/rc1.d/K10robinsrv
/etc/rc.d/rc0.d/K10robinsrv[/HTML]
it doesn't work then I change rc0, rc6 and create rc3 for kill process as sequence 01. Now it looks like this, but it is still not working.
[HTML][root@centos5 ~]# find /etc/rc.d -name K??robinsrv
/etc/rc.d/rc6.d/K01robinsrv
/etc/rc.d/rc2.d/K10robinsrv
/etc/rc.d/rc1.d/K10robinsrv
/etc/rc.d/rc3.d/K01robinsrv
/etc/rc.d/rc0.d/K01robinsrv[/HTML]
Can any one help me?
Thanks
Robin