Shell script simulates Nginx service startup and shutdown
Note: 3 slashes////is followed by a representation of the interpretation of the current statement, which must be removed in the actual script
#!/bin/bash///defines which scripting language interprets the following statement
[-f/etc/init.d/functions]&&. /etc/init.d/functions///Judge and load system functions
nginx= "/application/nginx/sbin/nginx"///nginx Service installation directory startup file
Start () {///define Start function
Instructions to be executed $nginx the///start function
}
Stop () {///define STOP function
Instructions to be executed $nginx-s stop//stop///stop function
}
Reload () {///define Reload function
Instructions to be executed $nginx-s reload///reload function
}
Case "$" in///case the value of the variable in the judgment statement "variable" in, calling the function defined above
Start
Start
;;/ End of current judgment, continue execution down
Stop
Stop
;;
Restart
Stop
Start
;;
Reload
Reload
;;
*///If the above variable value is not satisfied, then output echo after the content, the full path of the script
echo "usage:$0 {start|stop|restart|reload}"
Esac///case Judgment Statement End
CentOS6.8 x86_64bit shell scripting to simulate Nginx service startup and shutdown