首页  >  文章  >  数据库  >  机器关机或重启前时关闭mysql服务实例代码(收藏)

机器关机或重启前时关闭mysql服务实例代码(收藏)

PHPz
PHPz原创
2017-04-02 16:54:401542浏览

想让配置修改过的mysql能在机器关机或重启时能先停止mysql进程,防止数据异常

在/etc/init.d/下添加脚本,如下:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          test_shutdown
# Required-Start:    $syslog
# Should-Start: $time
# Required-Stop:     $syslog
# Should-Stop: $time
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: test_shutdown
# Description:       test_shutdown
### END INIT INFO
case "$1" in
start)
echo "start" >>/tmp/test.log
sleep 1;;
stop)
echo "begin stop" >>/tmp/test.log
su - test -c "/home/test/scripts/shutdown.sh"
echo "done stop" >>/tmp/test.log
;;
*)
echo "other" >>/tmp/test.log
esac
执行 chkconfig test_shutdown on

以上是机器关机或重启前时关闭mysql服务实例代码(收藏)的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn