nginx启动脚本

#!/bin/bash
#
#nginx-thisscriptstartsandstopsthenginxdaemin
#
#Bypiaomiao20131003
#chkconfig:-8515
#description:NginxisanHTTP(S)server.
#processname:nginx
NGINX=/usr/local/service/nginx/sbin/nginx
NGINXPID=/var/run/nginx.pid
NGINXCONGFILE=/usr/local/service/nginx/conf/nginx.conf
functiondo_start(){
if[-e$NGINXPID]
then
echo-e"Nginxalreadyrunning..."
else
echo-e"StartingNginx:...\t\t\t\t\t\t\c"
$NGINX-c$NGINXCONGFILE
echo-e"[\c"
echo-e"\033[;32mOK\033[0m\c"
echo-e"]\c"
echo-e"\r"
fi
}
functiondo_stop(){

if[-e$NGINXPID]
then
echo-e"StoppingNginx...\t\t\t\t\t\t\c"
kill-TERM`cat${NGINXPID}`
echo-e"[\c"
echo-e"\033[;32mOK\033[0m\c"
echo-e"]\c"
echo-e"\r"
else
echo"Nginxisalreadystopped..."
fi
}
functiondo_reload(){
if[-e$NGINXPID]
then
echo-e"ReloadingNginx...\t\t\t\t\t\t\c"
kill-HUP`cat${NGINXPID}`
echo-e"[\c"
echo-e"\033[;32mOK\033[0m\c"
echo-e"]\c"
echo-e"\r"
else
echo"Nginxisnotrunning..."
fi
}
case$1in
"start")
do_start
;;
"stop")
do_stop
;;
"restart")
do_stop
sleep1
do_start
;;
"reload")
do_reload
;;
*)
echo"Mustuse"$0"{start|stop|reload}"
exit3
;;
esac

你可能感兴趣的:(nginx启动,重启脚本)