nginx启动脚本
启动脚本
#!/bin/bash WORK_DIR=/data/nginx COMM_DIR=$WORK_DIR/sbin/nginx NAME=nginx PID=$WORK_DIR/logs/nginx.pid start() { if [ -f $PID ]; then echo "nginx is running" else $COMM_DIR if [ -f $PID ]; then echo "nginx is started" exit 0 else echo "nginx start is bad" exit 1 fi fi } stop() { if [ -f $PID ]; then $COMM_DIR -s stop echo "nginx is stoped" else echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)" exit 1 fi } restart() { if [ ! -f $PID ]; then echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)" else $COMM_DIR -s stop sleep 3 $COMM_DIR fi } reload() { if [ ! -f $PID ]; then echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)" else $COMM_DIR -s reload fi } chk() { if [ ! -f $PID ] then echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory" else $COMM_DIR -t fi } case $1 in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; chk) chk ;; *) echo "Usage:$0 {start|stop|restart|reload|ehk}" ;; esac