标签:linux bash
#! /bin/bashstart()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘ | wc -l
-lt 1 ];then
echo "Mysql service try to starting."
/bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
else:
echo "Mysql is running now."
#! /bin/bash
mysqluser=root
mysqlpass=123.com
mysqlpath=/usr/mysql/bin
mysqlprot=3306
start()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘ | wc -l
-lt 1 ];then
echo "Mysql service try to starting."
/bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
else
echo "Mysql is running now."
fi
}
stop()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘| wc -l
-ge 1 ];then
echo "Mysql service try to sotpping."
${mysqlpath}/mysqladmin -u ${mysqluser} -p ${mysqlpass} -S /data/${mysqlprot}/mysql.sock shutdown
else
echo "mysql is stopping now."
fi
}
restart()
{
stop
sleep 1
echo "The mysql service stopped."
start
sleep 1
echo "The mysql service starting."
}
case "$1" in:
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "usage:$0 {start|stop|restart}"
esac
标签:linux bash
原文地址:http://blog.51cto.com/546136/2086312