The Nginx service program written by Shell

Source: Internet
Author: User

the Nginx service program written by Shell
can be added to the/etc/init.d/directory first.
chkconfig--add nginxd
chkconfig nginxd on
Service Nginxd Start
Service Nginxd Stop
service Nginxd "Restart | Reload | Test | Status "

#!/bin/bash#chkconfig:-15#author:[email protected] #FUNC: Nginx service Script. #DATE: 2015-06-08#source function library. /etc/init.d/functions#source networking configuration. /etc/sysconfig/networknginx= "/usr/local/nginx/sbin/nginx" nginx_config_file= "/usr/local/nginx/conf/nginx.conf"    lockfile= "/var/lock/subsys/nginx" function start () {Test/usr/local/nginx/sbin/nginx retval=$?    If [$retval-eq 0] then touch $lockfile echo "Start Nginx OK!!!"    Fi return $retval}function stop () {killall nginx retval=$?    If [$retval-eq 0] then rm-f $lockfile echo "Stop Nginx OK!!!" Fi return $retval}function restart () {Stop start}function reload () {echo "Reload ......... ..."/usr/    Local/nginx/sbin/nginx-s Reload retval=$?    If [$retval-eq 0] then echo "Reload Nginx Configure OK!!!" Fi return $retval}function status () {if [-f $lockfile] then echoes "Nginx is Running ... "echo" Please useing ps-ef check process. "    Elseecho "Nginx is not Run ..." fi}function Test () {/usr/local/nginx/sbin/nginx-t retval=$?    If [$retval-eq 0] then touch $lockfile echo "Configure Test Nginx OK!!!"    Fi return $retval}case "in Start" echo "Nginx start ..." start;    Stop) echo "Nginx stop ..." STOP;    Restart) echo "Nginx restart ..." restart;;    Status) echo "Nginx status ..." status;;    Reload) echo "Nginx reload ..." reload;;    Test) echo "Nginx Configure test ..." test;; *) echo "useage: $ {start|stop|status|restart|reload|test}" exit 2;; Esac


The Nginx service program written by Shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.