在機器關機時關閉mysql服務實例

想讓配置修改過的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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章