Home > Database > Mysql Tutorial > body text

Code to close the mysql service instance before shutting down or restarting the machine (Collection)

PHPz
Release: 2017-04-02 16:54:40
Original
1584 people have browsed it

想让配置修改过的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
Copy after login

The above is the detailed content of Code to close the mysql service instance before shutting down or restarting the machine (Collection). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!