#!/bin/bash
basedir=/home/app/db/mysql
datadir=$basedir/data
conf=$basedir/etc/my.cnf
pid_file=$datadir/`/bin/hostname`.pid
MYSQLD="$basedir/bin/mysqld_safe --defaults-file=$conf"
usage(){
echo "usage:"
echo " $0 start|stop|reload|status "
exit 1
}
if test -z $1
then
usage
fi
STATUS=$pid_file
case "$1" in
"start")
if test -s "$STATUS"
then
echo "The MySQL is running ..."
echo $pid_file
else
sudo -u app -H $MYSQLD > /dev/null 2>&1 &
fi
;;
"stop")
pid=`cat $pid_file`
kill $pid > /dev/null 2>&1
echo "The MySQL is stop ..."
;;
"reload")
pid=`cat $pid_file`
kill -HUP $pid > /dev/null 2>&1
;;
"status")
if test -s "$STATUS"
then
echo "The MySQL is running..."
else
echo "The MySQL is down..."
fi
;;
*)
usage
exit 1
;;
esac
抄+改的