Results 1 to 8 of 8
I am experiencing a problem a problem trying to stop a daemon when the machine reboots or halts.
I have a script /etc/init.d/myprogram. This is then soft linked /etc/rc6.d/K99myprogram and ...
- 09-16-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 20
Start & Stop daemons in runlevels
I am experiencing a problem a problem trying to stop a daemon when the machine reboots or halts.
I have a script /etc/init.d/myprogram. This is then soft linked /etc/rc6.d/K99myprogram and /etc/rc0.d/K99myprogram. Within /etc/init.d, if I run "./myprogram stop," I see the script does go through the process of halting the process however, when I run reboot or halt the system, I don't see any behavior.
Any help would be greatly appreciated on how to resolve this issue.
- 09-16-2008 #2
Adding the soft link to the folder wont work, you need to use the following command:
Where PROGRAM is the executable in /etc/init.d/Code:sudo update-rc.d PROGRAM defaults
Linux User #453176
- 09-17-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 20
defaults
According to the man pages:
I've manually soft linked stuff to /etc/rc[016].d in Ubuntu. The version I'm currently using is Red Hat ES 4 which is having this problem.Code:If defaults is used then update-rc.d will make links to start the service in runlevels 2345 and to stop the service in runlevels 016.
- 09-20-2008 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
K99 will be run last of all, I think, so if the rest of the system has already shutdown, your script won't work. Generally, K-scripts should be number "100 - n" where n is the S-script number.
- 09-21-2008 #5Linux User
- Join Date
- Jun 2007
- Posts
- 318
I run Red Hat and have had similar problems. For the life of me I can't remember the exact reason why. The thing I did learn was to use chkconfig to set up the symlinks. Look at the manpage for details. You'll have put a couple of lines in the start/stop script for chkconfig as comments.
example:
# chkconfig: 345 44 56
# description: Listen and dispatch ACPI events from the kernel
- 09-22-2008 #6Just Joined!
- Join Date
- Mar 2008
- Posts
- 20
K99
Actually guys, the script is K89myscript. Not to make this into a debate but my attempt with this on Debian GNU/Linux has worked perfectly.
As you can see, there are multiple K<nn> scripts in this directory. Even when I stand in front of the console and do a reboot, I don't see all of these services stop.Code:radmin@redhat# ls /etc/rc6.d K01tog-pegasus K25sshd K74nscd K92arptables_jf K02cups-config-daemon K30sendmail K74ntpd K92iptables K02haldaemon K35vncserver K75netfs K94diskdump K02NetworkManager K35winbind K85mdmonitor K95kudzu K03messagebus K40smartd K85mdmpd K95openibd K03rhnsd K44rawdevices K86nfslock K96pcmcia K05anacron K50netdump K87auditd K99cpuspeed K05atd K50xinetd K87irqbalance K99lvm2-monitor K05saslauthd K56acpid K87portmap K99microcode_ctl K10cups K60crond K88syslog K99readahead K10dc_server K68rpcidmapd K88wpa_supplicant K99readahead_early K10psacct K69rpcgssd K89netplugd K99sysstat K10xfs K72autofs K89rdisc S00killall K12dc_client K73ypbind K89tis S01reboot K15gpm K74apmd K90bluetooth K20nfs K74ipmi K90network K24irda K74lm_sensors K91isdn
As to my understanding, any scripts with that begins with K stops and S starts. K99 might be the last script to stop but it should stop.
In addition, I've tried making the scripts with chkconfig. It worked perfectly fine but the end result was the same as what I would have done manually.
Any thoughts?Last edited by sprucio; 09-22-2008 at 02:40 PM. Reason: made an error with code
- 09-23-2008 #7Linux User
- Join Date
- Jun 2007
- Posts
- 318
How are you shutting down the system?
With shutdown or init 0.
Also, I'd suggest you put in the script an echo that writes to a file to verify it's not being run. Something like:
Code:date > /tmp/myscript.log echo "myscript stop" >> /tmp/myscript.log
- 09-23-2008 #8Just Joined!
- Join Date
- Mar 2008
- Posts
- 20
Red Hat
Hi guys,
It seems like this is a Red Hat issue as far as I can tell. I've tested this in Debian and Ubuntu and the desired behavior works out fine.
I've discovered the solution through the help of another member from this forum. If you do a search on my name, you should find another thread that explains this.
Basically, Red Hat creates files in /var/lock/subsys and pending on if the file exists, then it'll kill the appropriate services in the appropriate runlevels.


Reply With Quote
