标签:
#########################################################################
# File Name: nginx.sh
# Author: dty
# mail: 576786031@qq.com
# Created Time: Sun 09 Aug 2015 06:02:17 PM CST
#########################################################################
#!/bin/bash
. /etc/rc.d/init.d/functions
nginx=/usr/local/nginx/sbin/nginx
PID=/usr/local/nginx/logs/nginx.pid
prog=nginx
RETVAL=0
start(){
echo -n "Starting $prog ....."
$nginx -t &> /dev/null
if [ "$?" -eq 0 ];then
$nginx &>/dev/null && success || failure
fi
echo
RETVAL=$?
return $RETVAL
}
stop(){
echo -n "Stopping $prog:"
$nginx -s stop &> /dev/null && success ||failure
echo
RETVAL=$?
return $RETVAL
}
reload(){
echo -n "Stopping $prog:"
$nginx -s reload &> /dev/null && success ||failure
echo
RETVAL=?
return $RETVAL
}
case $1 in
start)
start;;
stop)
stop;;
restart)
stop
start;;
reload)
reload
;;
status)
status -p ${PID} $nginx
RETVAL=$?
;;
help)
$nginx -h
RETVAL=$?
;;
*)
echo usage(start|stop|restart|help|reload|);;
esac
exit $RETVAL
标签:
原文地址:http://my.oschina.net/loveleaf/blog/489797