Web Hosting Talk







View Full Version : Gracefully shutting down daemons


pmak0
11-07-2001, 08:08 AM
/etc/rc.d/rc.local is a script that gets executed when the machine starts up.

Is there a similar script that gets executed when the machine shuts down or reboots? I want to make sure that MySQL is stopped properly upon system reboots.

erik
11-07-2001, 09:07 AM
Take a look at these files:

/etc/init.d/halt
/etc/init.d/reboot

nexcess.net
11-07-2001, 05:41 PM
If you are starting your MySQL from an /etc/rc.d/init.d/mysql (or something similar) script then this already happens, if not it's pretty easy to setup and *may* be easier to maintain than putting code in the halt/reboot scripts.

pmak0
11-07-2001, 07:13 PM
Originally posted by nexcess.net
If you are starting your MySQL from an /etc/rc.d/init.d/mysql (or something similar) script then this already happens, if not it's pretty easy to setup and *may* be easier to maintain than putting code in the halt/reboot scripts.

I have /etc/rc.d/init.d/mysql. Just having the script there isn't enough to make it automatically start, though; I also have this line in /etc/rc.d/rc.local:

/etc/rc.d/init.d/mysql start

What do you mean "this already happens"? I don't see how simply having /etc/rc.d/init.d/mysql will automatically make it stop mysql when the server reboots. Were you thinking about the "/etc/rc3.d/S85mysql" type scripts (I don't like using those because I think I have to create multiple symlinks just for starting one daemon; simply putting the command to start it in rc.local seems a lot simpler, am I right?)?

nexcess.net
11-07-2001, 07:19 PM
sorry, my 'already happens' comment assumes that the mysql script was symlinked correctly by either the RPM or the chkconfig command..

you don't have do to any symlinking yourself to get the S85mysql type setup working. Just execute the following

chkconfig --add mysql
chkconfig --level 345 mysql on

the first command tells init to add mysql to its known startup scripts and the second tells it to start mysql on runlevels 345 and to shut it down on all other runlevels.

I agree that having to symlink everything your self would have been a huge pain but the 'chkconfig' type system works well.

Chris

bitserve
11-08-2001, 08:45 PM
Also, FYI, to use chkconfig to manage your rc scripts, you need to have a couple of headers on the scripts.

You need a line with the runlevels and priority for chkconfig, and a description.

Do a man on chkconfig, or just use:

# chkconfig: 345 84 13
# description: MySQL Server