program=/usr/local/nginx/sbin/nginx
pid=/usr/local/nginx/logs/nginx.pid
start(){
if [ -f $pid ];then
echo "nginx running"
else
$program
fi
}
stop(){
if [ ! -f $pid ];then
echo "nginx stop"
else
$program -s stop
echo "nginx stop"
fi
}
reload(){
$program -s reload
echo "nginx reloading complete"
}
status(){
if [ -f $pid ];then
echo "nginx running"
else
echo "nginx stop"
fi
}
case $1 in
start)
start;;
stop)
stop;;
reload)
reload;;
status)
status;;
*)
echo "your input error"
esac
閱讀更多 運維小筆記 的文章