[root@room9pc01 opt]# vim nginx.sh
#!/bin/bash
case $1 in
on)
/usr/local/nginx/sbin/nginx
[ $? -eq 0 ] && echo -e "\033[32m服务开启\033[0m" && exit;;
off)
/usr/local/nginx/sbin/nginx -s stop
[ $? -eq 0 ] && echo -e "\033[31m服务已关闭\033[0m" ;;
st)
netstat -ntulp | grep -q nginx
[ $? -eq 0 ] && echo "服务开启" || echo "服务未开启";;
re)
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx;;
*)
echo "on|off|st|re"
esac